Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feign does not proxy the methods inherited from interface if there are manually added ones #2240

Open
stsypanov opened this issue Nov 21, 2023 · 0 comments

Comments

@stsypanov
Copy link

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

@stsypanov stsypanov changed the title Feign Client does not proxy the methods inherited from interface if there are manually added ones Feign does not proxy the methods inherited from interface if there are manually added ones Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant