JSPM

  • Created
  • Published
  • Downloads 606126
  • Score
    100M100P100Q190062F
  • License MIT

Generates swagger doc based on JSDoc

Package Exports

  • swagger-jsdoc

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (swagger-jsdoc) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

swagger-jsdoc

This library reads your JSDoc-annotated source code and generates an OpenAPI (Swagger) specification.

npm Downloads CI

Please be aware that 6.x of the library does not yet support ESM.
Please use commonjs export style and rename your definition files with `.cjs`.

Getting started

swagger-jsdoc returns the validated OpenAPI specification as JSON or YAML.

const swaggerJsdoc = require('swagger-jsdoc');

const options = {
  swaggerDefinition: {
    openapi: '3.0.0',
    info: {
      title: 'Hello World',
      version: '1.0.0',
    },
  },
  apis: ['./src/routes*.js'],
};

const swaggerSpecification = swaggerJsdoc(options);
  • options.definition is also acceptable. Pass an oasObject
  • options.apis are resolved with node-glob. Construct these patterns carefully in order to reduce the number of possible matches speeding up files' discovery. Values are relative to the current working directory.

Use any of the swagger tools to get the benefits of your swaggerSpecification.

Installation

npm install swagger-jsdoc --save

Or

yarn add swagger-jsdoc

Supported specifications

  • OpenAPI 3.x
  • Swagger 2

Documentation

Detailed documentation is available within /docs folder.

Webpack integrations