Skip to content

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

Open
@takashno

Description

@takashno

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions