cancel
Showing results for 
Search instead for 
Did you mean: 

Java/Spring: web.xml servlet-mapping ignored by Swagger

kniffte
Occasional Visitor

Java/Spring: web.xml servlet-mapping ignored by Swagger

Forget about the following, I mixed up Swagger.io and Springfox

 

Hello,

we're having a web application, deployed as document.war, with a servlet-mapping "/rest" defined in web.xml. Therefore, endpoints are available using https://host:post/document/rest/ENDPOINT.

This url was picked up successfully by Swagger, exporting the endpoint using SwaggerUI version 2.

 

Now we're switching to Swagger version 3 OpenAPI, Swagger suddenly ignores the servlet-mapping, resolving the endpoint using https://host:post/document/ENDPOINT. I know, there is a configuration setting Docket.pathMapping(String) available, but using it e.g. ...build().pathMapping("huhu") leaders to the following endpoint urls in SwaggerUI: https://host:port/huhu/document/ENDPOINT.

 

Now, what do I need to do, in order to either configure Swagger to automatically apply the servlet-mapping setting from web.xml (my favourite) or to manually set the correct path https://host:port/document/rest/ENDPOINT ?

 

Thanks a lot.

Stefan

New Here?
Join us and watch the welcome video: