I am having a spring boot project and need to update my swagger path from
http://localhost:9012/swagger-ui.html
to
http://localhost:9012/myservice/swagger-ui.html
I am not using any context path for my application I have tried all the below approach but none of them worked.
Change location to call swagger-ui in Spring
https://github.com/springfox/springfox/issues/1443
How to change swagger-ui.html default path
https://github.com/springfox/springfox/issues/1080
How to change Swagger-ui URL prefix?
private static final String PATH = "/myservice";
@Override
public void addViewControllers(ViewControllerRegistry registry) {
final String apiDocs = "/v2/api-docs";
final String configUi = "/swagger-resources/configuration/ui";
final String configSecurity = "/swagger-resources/configuration/security";
final String resources = "/swagger-resources";
final String swaggerUI = "/swagger-ui.html";
registry.addRedirectViewController(apiDocs, PATH +apiDocs).setKeepQueryParams(true);
registry.addRedirectViewController(resources, PATH +resources);
registry.addRedirectViewController(configUi, PATH +configUi);
registry.addRedirectViewController(configSecurity, PATH +configSecurity);
registry.addRedirectViewController(swaggerUI, PATH + swaggerUI);
registry.addRedirectViewController("/",PATH);
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry){
registry.addResourceHandler(PATH + "/swagger-ui.html**").addResourceLocations("classpath:/META-INF/resources/swagger-ui.html");
registry.addResourceHandler(PATH + "/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
I am using swagger version 2.9.2 Is there any other way to resolve the issue.