如何从几个yaml规范生成swagger ui



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

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

至CCD_ 2。但是我怎样才能包括第二个API?

我试过了:

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

这创建了组合的http://localhost:8080/v3/api-docs/,但在http://localhost:8080/v3/api-docs/,尽管能够在顶部栏中的两个规格之间进行选择;未能加载API定义";两者都适用。

您可以使用属性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

您可以在文档中找到此属性。这个问题还有一个很好的常见问题解答:

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

最新更新