I am using swagger 3.0.0-SNAPSHOT with my spring-data-rest. I have context configure in my application property file
server.servlet.context-path=/sample/
my swagger configuration is as follows:
@Configuration
@EnableSwagger2WebMvc
@Import({springfox.documentation.spring.data.rest.configuration.SpringDataRestConfiguration.class})
public class SwaggerConfig {
@Bean
public Docket api(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
}
I am accessing my swagger ui as http://localhost:8080/sample/swagger-ui.html
all end point in swagger appear like
http://locahost:8080/sample/sample/getHello
http://locahost:8080/sample/sample/getName
http://locahost:8080/sample/sample/getAge
these urls should be
http://locahost:8080/sample/getHello
http://locahost:8080/sample/getName
http://locahost:8080/sample/getAge
How do I avoid swagger to add extra context root to endpoint
My RestController looks like
@RestController
public class HelloController {
@RequestMapping("/hello")
public String getHello(){
return "Hello";
}
@RequestMapping("/name")
public String getName(){
return "Sample Name";
}
@RequestMapping("/age")
public Integer getAge(){
return 37;
}
}
I have confirmed with a sample project that it is happening in every case