如何从 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/

我可以在本地主机中使用我的 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 路径,我们可以在应用程序 属性.[=23= 中使用 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