Insert a swagger specification into a markdown file.
$ npm install remark-swagger
path | method | summary |
/foo/bar | GET | get all bars in the area |
/bin/baz | PUT | add a new baz to the region |
const swagger = require('remark-swagger')
const remark = require('remark')
const fs = require('fs')
const spec = fs.readFileSync('./swagger-spec.json')
const readme = fs.readFileSync('./README.md')
const res = remark()
.use(swagger(spec, { position: 3, title: 'API' }))
.process(readme)
process.stdout.write(res, '\n')
Usage: remark-swagger [options] <markdown> [swagger]
Options:
-h, --help Output usage information
-v, --version Output version number
-y, --yaml Use swagger YAML instead of JSON
-p, --position Heading position, defaults to 4
-t, --title Heading title, defaults to API
-w, --write Persist changes to markdown file
Examples:
$ remark-swagger README.md swagger.json # Inject swagger into markdown
$ remark-swagger README.md < swagger.json # Inject swagger into markdown
Docs: https://github.com/yoshuawuyts/remark-swagger
Bugs: https://github.com/yoshuawuyts/remark-swagger/issues
- opts.yaml: parse a yaml string
- opts.json: parse a JSON string
- opts.position: header position to insert the table. Defaults to 3
- opts.title: header title for the table. Defaults to
'API'
.