You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
巴林闲侠
6f4dcd76d0
|
3 years ago | |
---|---|---|
.. | ||
bin | 3 years ago | |
node_modules/glob | 3 years ago | |
src | 3 years ago | |
CHANGELOG.md | 3 years ago | |
LICENSE | 3 years ago | |
README.md | 3 years ago | |
index.js | 3 years ago | |
package.json | 3 years ago |
README.md
swagger-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 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
Documentation
Click on the version you are using for further details: