【问题标题】:How to generate swagger-ui from several yaml specifications?如何从几个 yaml 规范生成 swagger-ui?
【发布时间】:2020-12-19 19:47:55
【问题描述】:

我有一个从 2 个规范文件生成 2 个 API 的 Spring Boot 应用程序。我可以通过添加为其中一个生成swagger-ui 页面

springdoc.swagger-ui.url=/firstAPI.yaml

application.properties。但是如何包含第二个 API?

我试过了:

springdoc.swagger-ui.urls=/firstAPI.yaml,/secondAPI.yaml

这会创建一个组合 http://localhost:8080/v3/api-docs/,但在 http://localhost:8080/v3/api-docs/ 尽管可以在顶部栏中的两个规范之间进行选择,但页面显示两者的“加载 API 定义失败”。

【问题讨论】:

标签: spring-boot swagger-ui openapi springdoc


【解决方案1】:

您可以使用属性urls

springdoc.swagger-ui.urls[0].name = first
springdoc.swagger-ui.urls[0].url = /firstAPI.yaml

springdoc.swagger-ui.urls[1].name = second
springdoc.swagger-ui.urls[1].url = /secondAPI.yaml

您可以在documentation 中找到此属性。这个问题还有一个很好的FAQ

属性springdoc.swagger-ui.urls.*,适合配置外部(/v3/api-docs url)。例如,如果您想在一个应用程序中聚合其他服务的所有端点。不要忘记 CORS 也需要启用。

【讨论】:

    猜你喜欢
    • 2019-09-07
    • 1970-01-01
    • 1970-01-01
    • 2016-06-29
    • 1970-01-01
    • 2017-07-08
    • 1970-01-01
    • 2018-02-21
    • 1970-01-01
    相关资源
    最近更新 更多