Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 938 Bytes

README.md

File metadata and controls

34 lines (26 loc) · 938 Bytes

swagger-parser-js

const swaggerJson = require('./path/to/your/swagger.json')
const Schema = require('swagger-parser-js')
const schema = new Schema(swaggerJson)

// get properties about the schema
schema.info()
schema.version()
schema.paths()
...
// you get it...

// the useful methods:
// returns an array of Operations
schema.operations()

// returns an array of Operations and also includes `consumes` and `produces` properties
schema.operationsWithRootInherited()

// returns a map of tags to an array of operations for that tag
schema.operationsWithTags()

// returns a map of tags to objects containing tag details and an array of operations
schema.taggedOperations()

// returns a map of tags to objects containing tag details and an array of operations
// each operation has an extra property `x-response-example`
schema.taggedOperationsWithExamples()

// TODO: document this way better
// use flow as documentation?