fastify / fastify-swagger

Swagger documentation generator for Fastify
MIT License
928 stars 204 forks source link

Allow adding additional static routes in addition to dynamic mode #798

Open navalex opened 5 months ago

navalex commented 5 months ago

Prerequisites

🚀 Feature Proposal

The goal would be to be able to have a static file (like yaml or anything like that) to details some routes statically, that come in addition to the dynamic generated doc. This would allow routes that the plugin can't read to the final documentation.

Motivation

The motivation come from my usage of Supertokens, an authentification provider. The SDK adds all auth routes, to manage sessions etc, but they do not use the Fastify router, instead they handle all request and check the route to determine if an auth action is called. They are doing like that to allow an easier maintainability for all Node.js http framework they supports.

Because of this implementation, Fastify-swagger can't detect those routes. And it would be really helpful to add those to my documentation, especially for the "Try out" function of the Swagger-ui, to easily login to try other routes.

Example

Don't really have a precise idea of how could it work, but probably defining a file like a static mode, but allow it to merge with the dynamic mode.

mcollina commented 5 months ago

I have no idea either, but it would be good to have indeed.