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

[REQ][Java][Spring][Feign] Support for specifying Feign fallback and fallbackFactory in spring-cloud client generation #20987

Open
takashno opened this issue Mar 28, 2025 · 1 comment

Comments

@takashno
Copy link
Contributor

takashno commented Mar 28, 2025

Is your feature request related to a problem? Please describe.

I'm using the spring generator with the library option set to spring-cloud to generate Feign clients. While the generated clients support specifying a configuration class, they do not currently support setting fallback or fallbackFactory.

This limitation makes it difficult to apply fallback logic, which is essential for resilience in production environments. Although many customizations can be handled via configuration classes or application.properties, fallback behavior seems to be an exception.

Describe the solution you'd like

It would be helpful if the generator could support specifying fallback and/or fallbackFactory for Feign clients in the generated code. Ideally, this could be handled via generator options or annotations, allowing users to plug in their custom fallback implementations easily.

Describe alternatives you've considered

Currently, I need to manually modify the generated code to set the fallback or fallbackFactory, which undermines the purpose of code generation. Other workarounds, such as programmatically wrapping the client, are more complex and not ideal.

Additional context

Feign provides a very convenient client abstraction, and when using OpenAPI + Java + Spring, it is a strong candidate for client generation. However, the lack of fallback support in the generated code is a blocker for production usage in many cases where resilience is critical.

There was also a similar request made in the past here: #1396

@takashno
Copy link
Contributor Author

Sorry, I forgot to mention this earlier.
The official Spring documentation for fallback and fallbackFactory in Spring Cloud OpenFeign is available here:
https://docs.spring.io/spring-cloud-openfeign/docs/current/reference/html/#spring-cloud-feign-circuitbreaker-fallback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant