Closed Xhale1 closed 1 year ago
I'd upvote for this issue 👍
I also upvote for this. I believe this is somwhere in the Swagger libraries itself https://stackoverflow.com/a/45282119/15313684
-- probably
hello @Xhale1 I don't know how you do, but a workaround would be to have an explicit head route, with an empty handler on top of the route in question, without tags and the otherone with tags:
This for instance:
// just to disable the route in autogenerated swagger UI
fastify.head('/meta', {
schema: {},
preHandler: rejectForeigners,
handler: async (request, reply) => {
return
},
})
fastify.get('/meta', {
schema: {
tags: ['meta'],
},
preHandler: rejectForeigners,
handler: async (request, reply) => {
return await api.meta()
},
})
Hey folks!
Looking at the PR that introduced support for HEAD routes on fastify swagger, I see there is an option to hide them available in the Fastify instance constructor
https://github.com/fastify/fastify-swagger/blob/master/test/spec/swagger/schema.js#L486
Hope this helps!
Thanks @Matheusbafutto for sharing this. It works 🎉
That's how I initialized Fastify instance to remove HEAD routes
const app = fastify({ exposeHeadRoutes: false });
It's cool that HEAD routes are now visible in swagger. But we need to allow opt-out for those who don't want it.
method
as an argument to the transform
method so that we could hide HEAD routes by method in custom schema transform logic.@dolsup I noticed and I've been fighting this. #724 should do the trick, take a look.
Prerequisites
🚀 Feature Proposal
Add an option to automatically hide HEAD routes.
Motivation
With release 8.4.0 HEAD routes are now supported (well done everyone!). For some use cases HEAD routes might not be needed in the swagger ui and their introduction could provide more clutter than utility.
Example
No response