Add "root-path" to swagger-ui#44981
Add "root-path" to swagger-ui#44981alexey-plotnikoff wants to merge 28 commits intoquarkusio:mainfrom
Conversation
gsmet
left a comment
There was a problem hiding this comment.
Thanks for the pull request!
I think we need to clarify the semantic here, also because I suppose this part is probably not the only part that would need tweaking.
Question: would it be possible to use relative paths instead and thus avoiding entirely this issue?
Good point. I'll check it. |
|
@gsmet current plugin generates all links with absolute path:
Do you mean I should change all these links to relative paths? |
|
\cc @MikeEdgar |
|
I agree that this seems like something that would be handled at a high level than just the Swagger UI. For example, the one link being configured is the |
|
Thank you @MikeEdgar! to: |
|
@MikeEdgar you solution with quarkus.http.non-application-root-path will change liveness and readiness probes in Kubernetes environment. |
|
I'm not sure if there are other components that should participate with a configuration like the one proposed. I'll let the others chime in on that. |
|
@cescoffier I think this one should be discussed with you. I'm not entirely sure how we can solve this issue globally. |
|
@cescoffier What do you think about this PR? |
| * If application behind the proxy with custom location path. | ||
| */ | ||
| @ConfigItem | ||
| Optional<String> locationPath; |
There was a problem hiding this comment.
Is it the root path for openapi?
There was a problem hiding this comment.
Maybe I should rename locationPath to rootPath?
|
|
||
| String openApiPath = nonApplicationRootPathBuildItem.resolvePath(openapi.path); | ||
| if (swaggerUiConfig.locationPath.isPresent()) { | ||
| openApiPath = swaggerUiConfig.locationPath.get() + openApiPath; |
There was a problem hiding this comment.
We may have to normalized the resulting path, or do we expect it to be consistent?
There was a problem hiding this comment.
Do you mean I should check a forward slash at the start of swaggerUiConfig.locationPath.get() if it doesn't exists?
There was a problem hiding this comment.
Yes, also that the given URL is normalized: https://en.wikipedia.org/wiki/URI_normalization
|
I don't believe we can use a global setting here. The global setting will affect the probes, metrics... Now in such kind of setup, the openapi page is considered public, while the probes (and metrics) are considered private. The easiest is clearly to configure the extension. We could imagine another option to declare the openapi routes to be part of the public API and mounted differently, but it will complexify the routing code. |
# Conflicts: # extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiConfig.java # extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java
|
@cescoffier I made some fixes. Take a look pls. |
|
@alexey-plotnikoff can you rebase? |
|
@alexey-plotnikoff Any chance for you to rebase the PR? |
So much changes! |
# Conflicts: # extensions/swagger-ui/deployment/src/main/java/io/quarkus/swaggerui/deployment/SwaggerUiProcessor.java
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@cescoffier could someone approve my changes to start GitHub Actions? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@cescoffier Merging is blocked by @gsmet from Mar 11, 2025. Looks like he doesn't like my PR 😢 |
|
It looks like there are merge commits. |
Status for workflow
|
Status for workflow
|


If the quarkus application behind proxy with custom location path swagger UI doesn't work correctly. This PR fix it.