admin管理员组文章数量:1221308
I'm implementing OpenAPI documentation in a Spring Cloud Gateway service that routes to multiple microservices. I've configured the gateway to aggregate Swagger documentation from different services using GroupedOpenApi.
My configuration includes:
- Spring Cloud Gateway
- springdoc-openapi
- Multiple downstream services with their own Swagger documentation
Current Implementation :
@OpenAPIDefinition
@Configuration
public class OpenAPIConfig {
@Bean
public List<GroupedOpenApi> apis() {
List<GroupedOpenApi> groups = new ArrayList<>();
gatewayProperties.getRoutes().forEach(route -> {
String name = route.getId();
GroupedOpenApi api = GroupedOpenApi.builder()
.group(name)
.pathsToMatch("/" + name + "/**")
.build();
groups.add(api);
});
return groups;
}
}
Configuration (application.yml) :
springdoc:
api-docs:
enabled: true
path: /v3/api-docs
swagger-ui:
enabled: true
config-url: /v3/api-docs/swagger-config
urls:
- name: auth-service
url: /auth-service/v3/api-docs
- name: multi-tenant-manager-service
url: /multi-tenant-manager-service/v3/api-docs
I have the Task Manager Service which is the only service user openapi.yml in resouces/static (and it renders fine in this service)
The issue I get:
Unable to render this definition
The provided definition does not specify a valid version field.
Please indicate a valid Swagger or OpenAPI version field. Supported version fields are swagger: "2.0" and those that match openapi: 3.x.y (for example, openapi: 3.1.0).
What I've Tried :
- Added ByteArrayHttpMessageConverter with supported media types
- Configured proper CORS settings
- Ensured all services' Swagger endpoints are accessible Question : How can I properly configure the OpenAPI/Swagger UI in Spring Cloud Gateway to aggregate and display documentation from multiple microservices? Are there any specific configurations or dependencies I'm missing?
This question format provides clear context, shows what you've attempted, and asks a specific question that others can help answer.
I was expecting the swagger ui to render as it did in the task manager service.
本文标签:
版权声明:本文标题:java - Spring Cloud Gateway: OpenAPISwagger UI not rendering properly with multiple service endpoints - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739257923a2155224.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论