Document your code and keep a live and reusable OpenAPI (Swagger) specification. This specification can be the core of your API-driven project: generate documentation, servers, clients, tests and much more based on the rich OpenAPI ecosystem of tools.
swagger-jsdoc enables you to integrate Swagger
JSDoc comments in your code. Just add
@swagger on top of your DocBlock and declare the meaning of your code in
yaml complying to the OpenAPI specification.
swagger-jsdoc will parse your documentation from
your actual living code and output an OpenAPI specification to integrate any server and client
technology as long as both sides comply with the specification.
swagger-jsdoc project assumes that you want document your existing working code in a way to "give life" to it, generating a specification which can then be feeded into other Swagger tools, and not the vice-versa.
If you prefer to write the OpenAPI specification first and separately, you might check other projects facilitating this, such as
$ npm install swagger-jsdoc --save
$ yarn add swagger-jsdoc
Get started by documenting your code.
swagger-jsdoc uses node glob module in the background when taking your files. This means that you can use patterns such as
There is an example app in the example subdirectory. To use it you can use the following commands:
$ git clone$ cd swagger-jsdoc$ npm install$ npm start
The swagger spec will be served at http://localhost:3000/api-docs.json
You can also use the tool via command line interface. It supports selecting multiple files, recursive subdirectories and watch task for continuous listening of changes in your code.
Note: If there are additions to the swagger definition object ensure that the output object keys comply with the swagger specification. If there are keys that do not comply add them to the
excludedSwaggerProperties list in