Closed
Description
Describe the feature
If you use https://spring.io/projects/spring-cloud-openfeign and define @FeingClients
with SpringMVCContract, SpringDoc shows this clients in OpenApi.
The problem is that this clients uses same annotations that RestControllers (@RequestMapping, @GetMapping ...)
To Reproduce
- Define @FeignClient
@FeignClient("feignclient")
@RequestMapping(value = "/api/v1/echo")
public interface EchoClient {
@GetMapping
String echo(@RequestParam int size);
}
- Call OpenApi endpoint
@Test
void givenFeignClient_whenGetAppApiDoc_thenDontAppear() {
given()
.when()
.get("/v3/api-docs/app")
.then().log().all()
.statusCode(200)
.body("paths['/api/v1/echo'].get", notNullValue());
}
Expected behavior
- This test must be ok:
@Test
void givenFeignClient_whenGetAppApiDoc_thenDontAppear() {
given()
.when()
.get("/v3/api-docs/app")
.then().log().all()
.statusCode(200)
.body("paths['/api/v1/echo'].get", nullValue());
}
Solution
Posibles solutions:
- Have an
annotationsToExclude
and passFeignClient.class
to exclude
return GroupedOpenApi
.builder()
.group(info.getArtifact())
.pathsToMatch("/api/**")
.annotationsToExclude(FeignClient.class)
.build();
- Shows only endpoints that have "@RestController" or "@controller" annotation by default. If beans don´t have this annotation, spring don´t exposes it as controller, and beans that aren´t exposed as controller, dont appear in open api endpoint.
- ...