I am using swagger-ui with spring. Here is my configuration class:
@Configuration
@EnableWebMvc
@EnableSwagger2
public class ApiDocsConfiguration extends WebMvcConfigurerAdapter {
@Bean
public Docket api() {
return new Docket(SWAGGER_2)
.apiInfo(apiInfo())
.select()
.paths(apiPaths())
.build();
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
//allow to get swagger ui html under /swagger-ui.html
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
//allow swagger ui to access resources under /webjars/springfox-swagger-ui/**
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
When I run locally, swagger endpoint is localhost:8080/swagger-ui.html. Does anyone know how to configure this so that the url is localhost:8080/api/swagger-ui.html
Thanks