首页 > 解决方案 > api网关后面的Springdoc configUrl

问题描述

我使用 spring 云网关路由/myapi 启动并运行 springdoc swagger ui。所以当我点击网址时

https://myhost.com/myapi

它把我重定向到一个网址

https://myhost.com/myapi/webjars/swagger-ui/index.html?configUrl=/swagger-config.json

我的 application.yml 文件中有以下代码

springdoc:
  swagger-ui:
    path: /
    configUrl: /swagger-config.json

我也设置了以下属性

server.forward-headers-strategy: framework

我的问题是我还需要做什么才能让重定向的 url 在配置 URL 中也包含 API 网关路由?基本上我希望重定向的网址是

https://myhost.com/myapi/webjars/swagger-ui/index.html?configUrl=/myapi/swagger-config.json

不是

https://myhost.com/myapi/webjars/swagger-ui/index.html?configUrl=/swagger-config.json

标签: spring-bootswagger-uiopenapispringdocspringdoc-openapi-ui

解决方案


我在 github ( https://github.com/springdoc/springdoc-openapi/issues/1144 ) 上收到了该项目的一位贡献者的回复。如果我们使用默认的 springdoc.swagger-ui.configUrl 而不是明确指定它,这一切都很好。


推荐阅读