seriousme / fastify-openapi-glue

A plugin for the Fastify webserver to autogenerate a Fastify configuration based on a OpenApi(v2/v3) specification.
MIT License
196 stars 33 forks source link

FEATURE REQUEST: Mark some routes as unrouted/static (no operationId logic) #569

Closed alexborisov closed 4 months ago

alexborisov commented 4 months ago

Hello, Thanks for this awesome library. I have a use case where my app runs on top of a common shared "platform". This provides a set of common utilities including some common routes (like a /health endpoint for CI/D). This stuff is lower level and I don't want to manage it through OpenAPI.

Right now if I add a route to my OpenAPI schema regardless of whether I set an operationId or not it will create a fastify route for this. Because I already create these routes outside if I try to add them to the document I get an error that the route is already defined. I would ideally like all the possible routes to be listed in the document.

One way would be to namespace the core routes, but I would like to avoid this. Since omitting an operationId will auto-gen the handler method name that logic should remain. Could we perhaps have some way to mark a route so it's ignored when generating the routes? Perhaps either as a custom x- prop on the openapi schema file or something in the plugin config (like an array of routes to ignore). Anything besides me having to code a custom operation resolver?

Thanks!

seriousme commented 4 months ago

Hi, thanks for asking!

Do I understand you correctly when I say that you:

  1. Do want the route to be in the openapi spec
  2. Don't want any fastify config generated for this route
  3. Do want to be able to use the default operations resolver and not provide a custom one

Kind regards, Hans

seriousme commented 4 months ago

I just released 4.5.0 on NPM that contains the x-no-fastify-config option, see README.md

Kind regards, Hans

alexborisov commented 4 months ago

That's awesome! Thanks so much 👍