fix(java): preserve Feign Jackson tagged oneOf variants

AN
1d ago
+282-0

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.