You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The resulting openapiSpecification will be a swagger tools-compatible (and validated) specification.
System requirements
Node.js 12.x or higher
You are viewing swagger-jsdoc v6 which is published in CommonJS module system.
Installation
npm install swagger-jsdoc --save
Or
yarn add swagger-jsdoc
Supported specifications
OpenAPI 3.x
Swagger 2
AsyncAPI 2.0
Validation of swagger docs
By default swagger-jsdoc tries to parse all docs to it's best capabilities. If you'd like to you can instruct an Error to be thrown instead if validation failed by setting the options flag failOnErrors to true. This is for instance useful if you want to verify that your swagger docs validate using a unit test.
constswaggerJsdoc=require('swagger-jsdoc');constoptions={failOnErrors: true,// Whether or not to throw when parsing errors. Defaults to false.definition: {openapi: '3.0.0',info: {title: 'Hello World',version: '1.0.0',},},apis: ['./src/routes*.js'],};constopenapiSpecification=swaggerJsdoc(options);
Documentation
Click on the version you are using for further details: