Allow contract composition · Issue #2666 · OpenFeign/feign · GitHub
Skip to content

Allow contract composition #2666

Open
Open

Description

@edudar

The feign client can support one contract only, and contracts tend to initialize themselves in the constructor. However, contracts are generally not mutually exclusive, and mixing, let’s say, default and spring contracts is totally possible if one transitions from one contract to another. My current workaround uses reflection and simply merges lists and maps of annotation processors of the two, which works because each contract supports its own set of annotations, so only one processor works at a time. It would be great if feign can provide composite contract out of the box that accept a list of contracts as an argument. The rest already works fine thanks to DeclarativeContract

Activity

  1. added
    enhancementFor recommending new capabilities
    proposalProposed Specification or API change
    on Jun 18, 2026
  2. velo commented on Jun 18, 2026

    @velo
    Member

    Thanks for spelling this out. A composite Contract sounds like a reasonable additive feature, as long as it does not change how existing single-contract clients behave.

    I would take a PR that introduces this as opt-in API, with tests covering mixed default/Spring-style annotation handling and precedence when more than one contract can interpret the same method. If you would rather sponsor/commission the work, I am available via GitHub Sponsors: https://github.com/sponsors/velo.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementFor recommending new capabilitiesproposalProposed Specification or API change

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions