How to change url that swagger serves resources to?

687 views
Skip to first unread message

kellzerIrl

unread,
Aug 7, 2015, 6:18:59 AM8/7/15
to Swagger
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
Reply all
Reply to author
Forward
0 new messages