【发布时间】:2020-07-18 13:03:11
【问题描述】:
我有一个部署在 Kubernetes 中的带有 open-api 3 的 Spring Boot 应用程序(spring-boot-starter-parent 2.2.4.RELEASE)。其余端点可通过入口访问,因此 URL 类似于:
https://host/ingress-path
我的问题是,一旦将应用程序部署到入口,api-docs 也可以通过以下方式获得:
https://host/ingress-path/v3/api-docs
当我打开 Swagger UI 时出现 404,因为 Swagger UI 似乎正在查看 https://host/v3/api-docs... 当我打开时
https://host/ingress-path/swagger-ui/index.html
并将https://host/ingress-path/v3/api-docs 放入“Expore”并运行它,我发现了我所有的 API。
谁能建议如何使用一些弹簧属性等为 UI 设置服务器?
目前我有这个(从 https://host/ingress-path/v3/api-docs.yaml 下载)
openapi: 3.0.1
info:
title: My API
description: My API description
version: v0.0.1
servers:
- url: https://host
description: Generated server url
此 API 是自动生成的。我想server 必须有url: https://host/ingress-path
似乎我需要具有相对路径的 pathProvider,如下所述:
https://github.com/springdoc/springdoc-openapi/issues/170
但我在 open-api 3 中找不到这样的东西。
你能帮帮我吗?
谢谢!
附:我想我可以通过配置修复它:
springdoc:
api-docs:
enabled: true
path: '/v3/api-docs'
swagger-ui:
path: '/swagger-ui'
config-url: '/ingress-path/v3/api-docs/swagger-config'
url: '/ingress-path/v3/api-docs'
doc-expansion: none
disable-swagger-default-url: true
【问题讨论】:
-
您找到解决方案了吗?
-
嗨@Varun。实际上我发布了可能的解决方案。我没有真正测试它,因为我们认为我们的服务不需要它。
标签: spring spring-boot swagger openapi