express-jsdoc-swagger icon indicating copy to clipboard operation
express-jsdoc-swagger copied to clipboard

Is it possible to write generated spec to file ?

Open Ilchuk-Mihail opened this issue 3 years ago • 4 comments

I see there are options exposeApiDocs and apiDocsPath, but the question, is it possible to write generated spec to file without running the express app?

This is very useful if you want to create script to generate spec and you don't need to run app with all dependencies.

Ilchuk-Mihail avatar Oct 26 '21 16:10 Ilchuk-Mihail

May be late to this, but if you use this pattern you can capture the event when it's finished (making sure to turn the server off during config)

const s = expressJSDocSwagger()(options)
s.on('finish', async (swagger_output) => {
  console.log(swagger_output)
})

makorihi avatar Mar 15 '22 04:03 makorihi

@makorihi : do you also know how to create a file during a Webpack build process?

mforell avatar Mar 24 '22 08:03 mforell

@mforell my build system is a bit different, but what I did was add the swagger generation command to my package.json script which runs my generation code. I'd suggest doing something like this before the webpack build command (or however else you do it)

"scripts": { "swagger": "node ./swagger.js" }

makorihi avatar Mar 24 '22 14:03 makorihi

Thank you very much. I was thinking about programming a webpack plugin, but your idea is much easier.

mforell avatar Mar 28 '22 12:03 mforell