DEV Community

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

Collapse
 
ogoiddev profile image
Diogo

Hi Luiz, how are you? ... to export more endpoints i just need put it inside of array right?

i mean like:
const endpointsFiles = [
'./routes/productsRouter.js',
'./routes/salesRouter.js',
];

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);