我无法在 swagger-ui 中显示我的 spring 文档。 这是我的配置:
springdoc:
# api-docs:
# enabled: true
# path: /v3/api-docs/swagger-config
swagger-ui:
# path: /swagger-ui.html
disable-swagger-default-url: true
# config-url: /v3/api-docs/swagger-config
# url: /v3/api-docs
我输入这个URL访问界面:http://localhost:8080/swagger-ui.html
问题是它没有显示从以下位置加载的 api 文档:
“http://localhost:8080/v3/api-docs/swagger-config”
状态:200。
但是如果我在 url 字段中输入这个,它会起作用..我的目标不是每次都输入这个..
我测试了一切可能的..我不明白为什么它不起作用
编辑: Swagger 配置
{"configUrl":"/v3/api-docs/swagger-config","oauth2RedirectUrl":"http://localhost:8080/swagger-ui/oauth2-redirect.html","url":"/v3/api-docs","validatorUrl":""}{"configUrl":"/v3/api-docs/swagger-config","oauth2RedirectUrl":"http://localhost:8080/swagger-ui/oauth2-redirect.html","url":"/v3/api-docs","validatorUrl":""}
最佳答案
我有一个类似的问题,并且能够通过更新 springdoc 演示项目“springdoc-openapi-spring-boot-2-webmvc”中的配置来重现它。 我定义了以下属性:
springdoc.api-docs.path=/test/v3/api-docs
sprindoc.swagger-ui.config-url=/test/v3/api-docs/swagger-config
springdoc.swagger-ui.path=/test/swagger-ui.html
通过该配置,我能够重现 OP 报告的问题。 为我修复的是添加一个额外的属性:
springdoc.swagger-ui.url=/test/v3/api-docs
希望这对您有所帮助。
关于spring - 未提供 API 定义 Swagger 无法显示文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71868266/