fastify-swagger-ui icon indicating copy to clipboard operation
fastify-swagger-ui copied to clipboard

Allow the swagger-ui url to be customised further

Open knolleary opened this issue 1 year ago • 2 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

@fastify/swagger-ui provides the routePrefix option that allows you to modify the default route prefix of /documentation. For example: /api-docs. This allows some level of customisation.

However, when you browse to the routePrefix, the plugin is hardcoded to redirect you to /api-docs/static/index.html.

I would like the swagger ui to be served from /api-docs/ without that redirection.

Is there a specific reason or limitation with the swagger-ui that requires this redirection? There may be some subtle aspects on how swagger-ui expects to load its own static assets that make this hard than it sounds.

I don't have a specific proposal at this stage for how this behaviour would be enabled in the configuration - most likely a boolean flag to disable the redirect... although what that gets called is open to suggestion.

Motivation

My main motivation here is trying to keep our application's URls consistent and tidy.

We don't use index.html in the path for any of our routes - I'd prefer the swagger-ui follows what we have elsewhere.

Example

No response

knolleary avatar Jan 10 '24 01:01 knolleary

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

mcollina avatar Jan 10 '24 06:01 mcollina

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

I've made a pull request #144 that implements this feature. I'd be grateful to those in this thread to see what they think.

jdhollander avatar May 01 '24 14:05 jdhollander