Gathering detailed insights and metrics for swagger-jsdoc
Gathering detailed insights and metrics for swagger-jsdoc
Gathering detailed insights and metrics for swagger-jsdoc
Gathering detailed insights and metrics for swagger-jsdoc
Generates swagger/openapi specification based on jsDoc comments and YAML files.
npm install swagger-jsdoc
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,704 Stars
442 Commits
228 Forks
11 Watching
9 Branches
69 Contributors
Updated on 28 Nov 2024
JavaScript (97.26%)
CSS (2.74%)
Cumulative downloads
Total Downloads
Last day
0.6%
120,236
Compared to previous day
Last week
-1.3%
625,937
Compared to previous week
Last month
4%
2,711,428
Compared to previous month
Last year
40.3%
25,430,060
Compared to previous year
This library reads your JSDoc-annotated source code and generates an OpenAPI (Swagger) specification.
Imagine having API files like these:
1/** 2 * @openapi 3 * /: 4 * get: 5 * description: Welcome to swagger-jsdoc! 6 * responses: 7 * 200: 8 * description: Returns a mysterious string. 9 */ 10app.get('/', (req, res) => { 11 res.send('Hello World!'); 12});
The library will take the contents of @openapi
(or @swagger
) with the following configuration:
1const swaggerJsdoc = require('swagger-jsdoc'); 2 3const options = { 4 definition: { 5 openapi: '3.0.0', 6 info: { 7 title: 'Hello World', 8 version: '1.0.0', 9 }, 10 }, 11 apis: ['./src/routes*.js'], // files containing annotations as above 12}; 13 14const openapiSpecification = swaggerJsdoc(options);
The resulting openapiSpecification
will be a swagger tools-compatible (and validated) specification.
You are viewing swagger-jsdoc
v6 which is published in CommonJS module system.
1npm install swagger-jsdoc --save
Or
1yarn add swagger-jsdoc
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.
1const swaggerJsdoc = require('swagger-jsdoc'); 2 3const options = { 4 failOnErrors: true, // Whether or not to throw when parsing errors. Defaults to false. 5 definition: { 6 openapi: '3.0.0', 7 info: { 8 title: 'Hello World', 9 version: '1.0.0', 10 }, 11 }, 12 apis: ['./src/routes*.js'], 13}; 14 15const openapiSpecification = swaggerJsdoc(options);
Click on the version you are using for further details:
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
38 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More