1

I have integrated Swagger into my Spring Boot Application. I am able to view the documentation created for a single Controller class , on the default swagger URL i.e - http://localhost:8081/swagger-ui.html#/

How can we change '/swagger-ui.html/' path to any other Custom path .

Also adding the code snippet. I want the url to be like :

http://localhost:8081/swagger#/

@Bean
public Docket usersApi(ServletContext servletContext){
    return new Docket(DocumentationType.SWAGGER_2).pathProvider(new RelativePathProvider(servletContext){
        @Override
        public String getApplicationBasePath() {
            return "/swagger" + super.getApplicationBasePath();
        }
    })
    .apiInfo(apiInfo())
    .select()
    .paths(PathSelectors.regex("/api/v1/.*" ))
    .build();
}

Thanks in Advance

Anurag Anand
  • 75
  • 1
  • 1
  • 11
  • 1
    Do these links answer your question? [How to change Swagger-ui URL?](https://stackoverflow.com/q/38510008/113116), [Change location to call swagger-ui in Spring](https://stackoverflow.com/q/46180375/113116) – Helen Jan 23 '20 at 09:33
  • I have tried the solution provided but it is not working. Also added Path Provider but it is not working for me. – Anurag Anand Jan 27 '20 at 07:21

0 Answers0