How to change swagger-ui endpoint that generates configuration (/v3/api-docs/swagger-config)
Solution 1:
I suppose I had a similar problem in the past and it was also related to Kubernetes and a proxy (API Gateway), which is in front of my application. I needed to have url like this https://host/api-gw/my-app/swagger-ui.html
and then redirection to https://host/api-gw/my-app/swagger-ui/index.html?configUrl=/api-gw/my-app/v3/api-docs/swagger-config
. The redirection didn't work properly for me, because the /api-gw/
part was missing in configUrl
parameter. The solution to my problem was adding ForwardedHeaderFilter (https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/filter/ForwardedHeaderFilter.html) bean to the configuration.
@Configuration
public class ForwardedHeaderFilterConfig {
@Bean
ForwardedHeaderFilter forwardedHeaderFilter() {
return new ForwardedHeaderFilter();
}
}
After that, redirection worked fine and the configUrl
parameter was set to api-gw/my-app/v3/api-docs/swagger-config
.