Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for noRedirect to serve UI directly at the route prefix #144

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jdhollander
Copy link

This PR is related to #117. I like the suggestion, and it would be beneficial to me to have this feature, so I've implemented it.

Checklist

noRedirect option

I have introduced a new option, which will disable the redirect to /static/index.html for the documentation UI. On visiting the documentation route, the UI is returned without redirection, and the url stays clean.

await fastify.register(require('@fastify/swagger-ui'), {
  routePrefix: '/documentation',
  noRedirect: true,
})

.prettierignore Outdated Show resolved Hide resolved
Copy link
Collaborator

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noRedirect is not about not redirecting but actually about some routing option. This seems kind of wrong.

@jdhollander
Copy link
Author

noRedirect is not about not redirecting but actually about some routing option. This seems kind of wrong.

Thanks for the feedback. Any suggestion on what I should call it? serveIndexAtRootPrefix? noStaticIndexRedirect?

Otherwise, is the general approach to this ok?

@Uzlopak
Copy link
Collaborator

Uzlopak commented May 2, 2024

Why do we even redirect? I have unfortunately currently no motivation to deep dive into the topic. But maybe not redirecting but directly serving the expected files should be the desired result?

Maybe related to
fastify/fastify-swagger#39
fastify/fastify-swagger#56
fastify/fastify-swagger#65

@mcollina
Copy link
Member

mcollina commented May 2, 2024

I did the redirect because I was too lazy to figure out how to make that rendering work correctly. At the beginning, the HTML was entirely static, so just redirecting it makes sense.

Maybe we should flip it to true by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants