相关疑难解决方法(0)

使用 Spring Security 允许匿名访问 springdoc-openapi-ui

如何在 Spring Security 保护的 Spring Boot 应用程序中允许匿名访问springdoc-openapi-ui (OpenAPI 3.0 /swagger-ui.html)?

java spring spring-security openapi springdoc

7
推荐指数
1
解决办法
3736
查看次数


Springdoc OpenAPI ui 不支持“位置”中的上下文路径

设置:

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

5
推荐指数
2
解决办法
3906
查看次数