如何在 Spring Security 保护的 Spring Boot 应用程序中允许匿名访问springdoc-openapi-ui (OpenAPI 3.0 /swagger-ui.html)?
我正在使用springdoc-openapi-ui,当我点击http://localhost:8080/swagger-ui.html URL 时,它总是重定向到http://localhost:8080/swagger-ui/index.html?configUrl=/v3/api-docs /招摇配置。有什么方法可以阻止这种重定向并在http://localhost:8080/swagger-ui.html上加载 swagger 。
我springdoc-openapi-ui在一个简单的 spring-boot 项目中使用1.4.0 版本(通过 Maven)中的 Java 库,没有任何自定义。
Swagger 页面在https://my-url.com/my-context-path/swagger-ui/index.html下生成
和https://my-url.com/my-context-path/v3/api-docs/下的 api-docs
这两个都有效,我可以联系到他们。到现在为止还挺好!
当简单地导航到https://my-url.com/my-context-path/swagger-ui.html 时,我得到一个 HTTP 状态 302 和一个location在响应头中设置的属性,它应该将我重定向到 swagger 页面从上面(我假设)。
但是,location属性中的 URL缺少上下文路径!它看起来像这样:https :
//my-url.com/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config
它重定向到一个不存在的页面,我收到 404 错误代码。请注意,configUrl 似乎也缺少上下文路径。
任何想法为什么会发生这种情况以及如何解决?
这个 Github 问题似乎是同样的问题,但最后声明问题已解决:https : //github.com/springdoc/springdoc-openapi/issues/37,这是针对比我更早的版本。
swagger swagger-ui springdoc springdoc-ui springdoc-openapi-ui
springdoc ×2
swagger ×2
swagger-ui ×2
java ×1
openapi ×1
spring ×1
spring-boot ×1
springdoc-ui ×1