swagger-core
swagger-core copied to clipboard
How to fix URLs displayed in Swagger UI?
I am running my APIs with servlet path /restapis, and Swagger UI with servlet path /. My auto-generated /restapis/openapi.json renders in Swagger UI, but the paths are wrong.
- Rendered URL => http://localhost:8443/resource1
- Expected URL => http://localhost:8443/restapis/resource1
I am launching Jetty 9.4.22.v20191022 from a POJO. Context path is /, and there are two servlets.
- /restapis => Jersey 2.29.1 Servlet with init parameter (jersey.config.server.provider.classnames=io.swagger.v3.jaxrs2.integration.resources.OpenApiResource,com.example.rest.Resource1)
- / => Jetty Default Servlet with welcome files = {index.html}, and context base = unpacked Swagger UI 3.24.3 directory.
The unpacked index.html is modified to replace the default URL, similar to how https://github.com/swagger-api/swagger-ui/blob/master/docker/run.sh#L35 is substituting it.
- Original => url: "https://petstore.swagger.io/v2/swagger.json"
- Replacement => url: "http://localhost:8443/restapi/openapi.json"
In Swagger UI, I expect to see /restapis/resource1, but it shows /resource1 instead. If I use Swagger UI to try to execute that API, Swagger UI displays HTTP 404 response from the API.