feign
feign copied to clipboard
Feign does not proxy the methods inherited from interface if there are manually added ones
In my project I have common module with API interfaces generated from OpenAPI spec:
@Generated(value = "org.openapitools.codegen.languages.SpringCodegen")
@Validated
@Tag(name = "Account Information", description = "Search and view customer accounts")
public interface AccountsApi {
default Optional<NativeWebRequest> getRequest() {
return Optional.empty();
}
@RequestMapping(
method = RequestMethod.GET,
value = "/accounts",
produces = {"application/json"}
)
default ResponseEntity<Accounts> searchForAccounts(
@Parameter(name = "accountIds", description = "Comma separated list of account ids", in = ParameterIn.QUERY) @Valid @RequestParam(value = "accountIds", required = false) List<String> accountIds
) {
getRequest().ifPresent(request -> {
for (MediaType mediaType : MediaType.parseMediaTypes(request.getHeader("Accept"))) {
if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
String exampleString = "null";
ApiUtil.setExampleResponse(request, "application/json", exampleString);
break;
}
}
});
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
}
There are two modules with Feign clients implementing this interface:
//module A
@FeignClient(name = "accountClient", url = "${accounts.internal.api.url}")
public interface AccountsClient extends AccountsApi {
}
//module B
@FeignClient(name = "accountClient", url = "${accounts.internal.api.url}")
public interface AccountsClient extends AccountsApi {
@GetMapping
ResponseEntity<Accounts> getAccounts(@RequestParam("customerXRef") String customerXRef);
}
The problem I'm facing is that the second client (in module B) proxies only the calls to getAccount() and for all the methods inherited from AccountsApi e.g. (AccountsApi.searchForAccounts()) returns 501 (NOT_IMPLEMENTED).
How can I fix this and have proxy for inherited methods either?
I use Spring Boot 2.7.17 and org.springframework.cloud:spring-cloud-starter-openfeign:3.1.8.
Originally it was question on StackOverflow: https://stackoverflow.com/questions/77515201/feign-client-does-not-proxy-the-methods-inherited-from-interface-if-there-are-ma