Skip to content

yoshuawuyts/remark-swagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

remark-swagger stability

npm version build status test coverage downloads js-standard-style

Insert a swagger specification into a markdown file.

Installation

$ npm install remark-swagger

Example output

path method summary
/foo/bar GET get all bars in the area
/bin/baz PUT add a new baz to the region

Usage

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')

CLI

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

API

remarkSwagger

  • 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'.

See Also

License

MIT

About

Insert a swagger specification into a markdown file

Resources

License

Stars

Watchers

Forks

Packages

No packages published