Reputation: 334
I'm using swagger to describe my Rest API
So, this is the swaggerConfig.java
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.tags(
new Tag("Session", "All About Session", 1)
)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("My Rest API")
.version("1.0.0")
.build();
}
My web-service is deployed on this link http://localhost:2080/ws1.1/
Swagger is accessible via http://localhost:2080/ws1.1/swagger-ui.html
Now, i setup an Apache server proxy like this
<VirtualHost *:80>
ServerName cc.com
....
ProxyPass /stable http://localhost:2080/ws1.1/
ProxyPassReverse /stable http://localhost:2080/ws1.1/
<Location "/webapps">
Order deny,allow
Allow from all
</Location>
</VirtualHost>
with this configuration, swagger-ui is available via http://cc.com/stable/swagger-ui.html
Until that, everything is OK
But when i try to run any endpoint of my API, swagger generate a bad URL
this is the generated URL : http://cc.com/ws1.1/login?login=user&passwd=psw
-> KO
I expect this URL : http://cc.com/stable/login?login=user&passwd=psw
Upvotes: 0
Views: 734
Reputation: 1898
You can try to set this property to your Docket
:
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.pathMapping("/stable")
It will add a servlet path mapping to your endpoint's url.
Upvotes: 1