【发布时间】:2021-05-23 22:30:52
【问题描述】:
我仍然有“禁用”问题...
我的swagger界面url配置为/swagger-ui.html (它重定向到 /swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config =>这是正常的!) 但是默认的 swagger url ( PetStore ) 仍然可以通过 /swagger-ui/index.html 访问(所以通过从 "?" 中删除所有内容)。
我必须解决这个问题,因为它被视为一个安全问题......
有 4 种方法来配置它,但我使用了 swagger-ui yaml 文件: https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/
我的 application.yaml :
springdoc:
swagger-ui:
path: '/swagger-ui.html'
configUrl: '/v3/api-docs/swagger-config'
disable-swagger-default-url: true
但这不会禁用宠物商店。我不知道为什么:-(
我正在使用 springdoc openapi 1.5.7(在 build.gradle 中):
implementation('org.springdoc:springdoc-openapi-ui:1.5.7') {
exclude group: 'javax.validation', module: 'validation-api'
}
我在配置中将路径从“/swagger-ui.html”更改为路径:“/swagger_ui.html”(并再次运行应用程序)此更改有效,所以我不明白为什么它不禁用默认招摇网址。
我在 stackoverflow 上阅读了很多主题,我知道所写的内容,我在需要“配置”的文件(application.properties 或 application.yaml)中得到了答案
【问题讨论】:
-
非常感谢!!该主题本身没有给出解决方案,我去了给定的链接,但有人给出了一个带有 swagger-ui 配置的链接,我不知道但它有效!非常感谢!
标签: java swagger openapi springdoc