简体   繁体   English

如何从application.properties设置springfox.documentation.swagger.v2.path

[英]how to set the springfox.documentation.swagger.v2.path from application.properties

I am using Swagger2 in my Java based REST API. 我在基于Java的REST API中使用Swagger2。 The basepath of the API has been set from the application.properties file API的基本路径已从application.properties文件中设置

server.contextPath=/myapi/v1/

I could access the endpoints using my Swagger UI in localhost as in the following URL: 我可以在localhost中使用我的Swagger UI访问端点,如以下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: 但是我无法从以下URL访问JSON API文档:

http://localhost:8080/myapi/v1/api-docs

The JSON API doc has been shown in: JSON API文档已显示在:

http://localhost:8080/myapi/v1/v2/api-docs

An extra path v2 is showing now. 现在显示额外的路径v2 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. 我读了一些文章,说这是因为Swagger2默认的api-docs路径,我们可以在应用程序属性中使用springfox.documentation.swagger.v2.path属性覆盖路径。

How can I set the v2 path to http://localhost:8080/myapi/v1/api-docs ? 如何将v2路径设置为http://localhost:8080/myapi/v1/api-docs Through the application.properties ? 通过application.properties I have been trying different paths but not getting the right result. 我一直在尝试不同的路径,但没有得到正确的结果。

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 设置上述应用程序属性有助于我在正确的路径中获取api-docs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM