Skip to content

fix(java): preserve Feign Jackson tagged oneOf variants - #25531

Open
AndreyVMarkelov wants to merge 2 commits into
OpenAPITools:masterfrom
AndreyVMarkelov:andreymarkelov/fix-feign-jackson-tagged-oneof
Open

AndreyVMarkelov wants to merge 2 commits into
OpenAPITools:masterfrom
AndreyVMarkelov:andreymarkelov/fix-feign-jackson-tagged-oneof

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Description

Preserve object oneOf variants in Java Feign/Jackson clients when the variants have a common required string property with distinct single-value enums. For an open variant, accept not: enum when it excludes exactly the known tag values.

Generate a Jackson-polymorphic interface with subtype mappings and a fallback for the open variant. Closed unions reject unknown tags. This fixes loss of variants such as Dropbox FilesMetadata during deserialization.

This is limited to tagged unions whose variants can be identified from the schema. It does not add general oneOf validation or standalone not: enum property validation. Related okhttp-gson validation work: #25066.

Tests

  • JavaClientCodegenTest#testFeignJacksonTaggedOneOf.
  • Generated-client runtime test for closed and open tagged unions, including known and unknown tags.
  • Generated and compiled the full Dropbox public SDK with --library feign --additional-properties=serializationLibrary=jackson; verified FilesMetadata file, folder and deleted variants and CommonRootInfo known and fallback variants.
  • Regenerated the Feign sample configurations.

The generated-client runtime fixture was copied into the generated client's test directory and run with Maven.

PR checklist

  • Read the contribution guidelines.
  • Run the full project build, regenerate all samples and export generator docs.
  • Notify the relevant technical committee members.

Summary by cubic

Preserves object oneOf variants in Java Feign/Jackson clients when variants share a required string tag with distinct single-value enums. Previously such variants were lost during deserialization; now they generate a Jackson-polymorphic interface with subtype mappings, a fallback for the open variant, and an InvalidVariant stub on closed unions that throws on unknown tags.

Limited to tagged unions whose variants are identifiable from the schema. Does not add general oneOf validation or standalone not: enum property validation. Adds a CI workflow that generates a client from the new fixture and runs the runtime deserialization test.

Tests

  • testFeignJacksonTaggedOneOf checks the generated interface, subtype mappings, and fallback class.
  • Generated-client runtime test covers closed and open unions with known and unknown tags.
  • Built the full Dropbox SDK with Feign and Jackson; verified FilesMetadata file, folder, and deleted variants and CommonRootInfo fallback behavior.
  • Regenerated the Feign sample configurations.

Written for commit fc2c99e. Summary will update on new commits.

View guided diff

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 5 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant