If the module is installed globally, a command line helper $ swagger-jsdoc
will be available.
Otherwise ./bin/swagger-jsdoc
has access to the same interface.
The easiest way to get started is using the help menu.
$ swagger-jsdoc -h
Swagger-jsdoc will read the apis
array in your definition file by default for file paths it should read.
$ swagger-jsdoc -d swaggerDef.js -o doc.json
This could be any .js or .json file which will be require()
-ed and parsed/validated as JSON.
$ swagger-jsdoc route1.js route2.js
Free form input, can be before or after definition. Glob patterns are acceptable to match multiple files with same extension *.js
, *.php
, etc. or patterns selecting files in nested folders as **/*.js
, **/*.php
, etc.
$ swagger-jsdoc -o custom_specification.json
swagger.json
by default. Output specification can accept also a .yaml
or .yml
. This generated OpenAPI specification can then be further tweaked with swagger-editor
or similar.
$ swagger-jsdoc -d swaggerDef.js route1.js route2.js -w
The -w
flag starts a watch task for input files with API documentation. This may be particularly useful when the output specification file is integrated with Browsersync
with Swagger UI or ReDoc. Thus, the developer updates documentation in code with fast feedback in an interface showing live documentation based on the OpenAPI specification.