繁体   English   中英

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

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

我在基于Java的REST API中使用Swagger2。 API的基本路径已从application.properties文件中设置

server.contextPath=/myapi/v1/

我可以在localhost中使用我的Swagger UI访问端点,如以下URL中所示:

http://localhost:8080/myapi/v1/swagger-ui.html

我的终点工作得很好。 但是我无法从以下URL访问JSON API文档:

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

JSON API文档已显示在:

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

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

如何将v2路径设置为http://localhost:8080/myapi/v1/api-docs 通过application.properties 我一直在尝试不同的路径,但没有得到正确的结果。

server.contextPath=/MyAppName/v1
springfox.documentation.swagger.v2.path=/api-docs

设置上述应用程序属性有助于我在正确的路径中获取api-docs

暂无
暂无

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

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