我正在研究是否可能有一个中央的swagger UI,您可以在其中看到来自多个本地主机的/v3/api-docs。
我的想法是让多个GroupedOpenApi
Beans都转到不同的本地主机。例如:
@Bean
public GroupedOpenApi apimicroservice() {
String service = discoveryClient.getServices().get(0);
return GroupedOpenApi.builder().group("microservice-test").pathsToMatch(
//Here the api-docs of the given host, example:
"http://localhost:8080/v3/api-docs"
//Or like how I want it with eureka:
"http://" + service + "/v3/api-docs"
).build();
}
这有可能吗?也许不是用GroupedOpenApi,而是别的什么?
现在,当我为@Bean
创建多个GroupedOpenApi时,它可以工作,但我希望它是带有List<GroupedOpenApi>
的1bean,但在我的UI中不起作用。这个是可能的吗?
提前感谢!
发布于 2022-04-06 02:25:23
对于集中式的swagger,您需要顶部的抽象(如api网关)来组合响应。
参考文献:https://piotrminkowski.com/2020/02/20/microservices-api-documentation-with-springdoc-openapi/
完全归功于皮奥特制作本教程。
https://stackoverflow.com/questions/71763166
复制相似问题