I'm trying to change base access url for API documentation. The url is "http://localhost:8080/swagger-ui.html". I want to get something like "http://localhost:8080/myapi/swagger-ui.html".
I use Springfox 2.8.0 Swagger, Java 8, Spring Boot 2.0The swagger configuration is:
@Configuration@EnableSwagger2public class SwaggerConfiguration { @Bean public Docket api(ServletContext servletContext) { return new Docket(DocumentationType.SWAGGER_2) .pathProvider(new RelativePathProvider(servletContext) { @Override public String getApplicationBasePath() { return "/myapi"; } }) .select() .apis(RequestHandlerSelectors.any()) .paths(Predicates.not(PathSelectors.regex("/error"))) .build() .useDefaultResponseMessages(false); }}
Custom path provider had to help, but I still get access to api documentation by using url "http://localhost:8080/swagger-ui.html". If I use url "http://localhost:8080/myapi/swagger-ui.html", I get 404 error. Look at the screenshot below.