DEV Community

Discussion on: Autogenerated documentation API with OpenAPI and Swagger for NodeJS and Express

Collapse
 
luizcalaca profile image
Luiz Calaça

Certainly, Diogo! Just include all routes into endpointFiles like you wrote.

Collapse
 
luizcalaca profile image
Luiz Calaça • Edited

Your example is exactly what is writing on documentation: github.com/davibaltar/swagger-auto...

const outputFile = './path/swagger-output.json';
const endpointsFiles = ['./path/endpointsUser.js', './path/endpointsBook.js'];

/* NOTE: if you use the express Router, you must pass in the
'endpointsFiles' only the root file where the route starts,
such as index.js, app.js, routes.js, ... */

swaggerAutogen(outputFile, endpointsFiles);