Surnet/swagger-jsdoc
Surnet/swagger-jsdoc has 1,791 GitHub stars and 229 forks. GitHot measured 0 stars in 24 hours. Last checked 2026-11-08 01:24 UTC. Last push 2026-11-01.
Generates swagger/openapi specification based on jsDoc comments and YAML files.
Measured star growth
- in 24h
- 0
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
Originalswagger-jsdoc
This library reads your JSDoc-annotated source code and generates an OpenAPI (Swagger) specification.
Getting started
Imagine having API files like these:
/**
* @openapi
* /:
* get:
* description: Welcome to swagger-jsdoc!
* responses:
* 200:
* description: Returns a mysterious string.
*/
app.get('/', (req, res) => {
res.send('Hello World!');
});
The library will take the contents of @openapi (or @swagger) with the following configuration:
const swaggerJsdoc = require('swagger-jsdoc');
const options = {
definition: {
openapi: '3.0.0',
info: {
title: 'Hello World',
version: '1.0.0',
},
},
apis: ['./src/routes*.js'], // files containing annotations as above
};
const openapiSpecification = swaggerJsdoc(options);
The resulting openapiSpecification will be a swagger tools-compatible (and validated) specification.

System requirements
- Node.js 20.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.
const swaggerJsdoc = require('swagger-jsdoc');
const options = {
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'],
};
const openapiSpecification = swaggerJsdoc(options);
Documentation
Click on the version you are using for further details:
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
560,935 starspublic-apis/public-apis
A collective list of free APIs
497,198 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
442,535 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,178 stars