Reputation: 451
I am using Swagger2 in my Java based REST API. The basepath of the API has been set from the application.properties
file
server.contextPath=/myapi/v1/
I could access the endpoints using my Swagger UI in localhost as in the following URL:
http://localhost:8080/myapi/v1/swagger-ui.html
And my end points work fine. But I am not able to access the JSON API doc from the following URL:
http://localhost:8080/myapi/v1/api-docs
The JSON API doc has been shown in:
http://localhost:8080/myapi/v1/v2/api-docs
An extra path v2
is showing now. I read certain articles saying that this is because of the Swagger2 default api-docs path and we can override the path using springfox.documentation.swagger.v2.path
property in application property.
How can I set the v2
path to http://localhost:8080/myapi/v1/api-docs
? Through the application.properties
? I have been trying different paths but not getting the right result.
Upvotes: 3
Views: 16236
Reputation: 451
server.contextPath=/MyAppName/v1
springfox.documentation.swagger.v2.path=/api-docs
Setting the above application properties helped me getting the api-docs in right path
Upvotes: 8