Hi is there is any possibility to save API swagger YAML to local file when starting the project? I'm using fastify-swagger plugin
using exposeRoute enable true and call '/documentation/yaml' API allowed to download YAML via the browser but i need to generate and save this YAML file to local inside the project when initially start the project.
Yes, you can do it like this:
// .. your code
fastify.register(require('fastify-swagger'), { ... })
await fastify.listen(8080)
// after the ready or listen call
const yaml = fastify.swagger({ yaml: true })
require('fs').writeFileSync('./swagger.yml', yaml)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.