Closed
Description
Is your feature request related to a problem? Please describe.
- Trying to configure springdoc to serve a custom openapi.json file behind a reverse proxy. Where the default page should have that file be selected in a context path aware manner.
- When the property
springdoc.swagger-ui.url
is set to/openapi.json
I expect the path to be context path aware. Similar to how the normal api-docs is handled.
Describe the solution you'd like
- When defining a local url / file in the
springdoc.swagger-ui.url
i expect it to handle being served behind a reverse proxy.
(of course given that the reverse proxies sets the correct headersX-Forwarded-Prefix
/ similar.) - Expanding on it; When defining a local file/url in
springdoc.swagger-ui.url
it is expected that such a url is handled in a context path aware manner.
Describe alternatives you've considered
I've considered hacks around it, such as defining the static file with the prefix of the reverse proxy in it. But that means any local testing will not work.
Looking into the code I have considered changing the following method somehow as that is where the url is being modified. And from what I can see it might be possible to do something around String swaggerUiUrl = swaggerUiConfig.getUrl();
line to handle it in a similar way as done in buildApiDocUrl()
.
protected void buildConfigUrl(UriComponentsBuilder uriComponentsBuilder) {
if (StringUtils.isEmpty(swaggerUiConfig.getConfigUrl())) {
apiDocsUrl = buildApiDocUrl();
swaggerConfigUrl = buildSwaggerConfigUrl();
swaggerUiConfigParameters.setConfigUrl(swaggerConfigUrl);
if (CollectionUtils.isEmpty(swaggerUiConfigParameters.getUrls())) {
String swaggerUiUrl = swaggerUiConfig.getUrl();
if (StringUtils.isEmpty(swaggerUiUrl))
swaggerUiConfigParameters.setUrl(apiDocsUrl);
else
swaggerUiConfigParameters.setUrl(swaggerUiUrl);
}
else
swaggerUiConfigParameters.addUrl(apiDocsUrl);
}
calculateOauth2RedirectUrl(uriComponentsBuilder);
}
Additional context
Also would be fine with any other possibilities such as a flag to make ``springdoc.swagger-ui.url` context aware or any suggestions!