Fix oneOf deserialization for parameterized types #3193
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.

Context
PRs #3177 and #3180 fixed oneOf types with type erasure collisions (e.g.,
List<String>andList<Double>) by:However, the deserialization side was not fixed, causing test failures in PR #3057.
Issue
When deserializing JSON for oneOf types with parameterized types that have the same erasure, the deserializer uses
.classwhich loses generic type information:This causes
match = 2, leading to a fallback that tries to deserialize the array as aMap<String, Object>, resulting in:This failure occurred in PR #3057 when testing
CustomAttributeValuesUnionwithoneOf: String, List<String>, Double, List<Double>.Changes
Updated
.generator/src/generator/templates/modelOneOf.j2to useTypeReference<T>for parameterized types instead of.class:is_parameterized_type()helper informatter.pyto detect generic typescli.pyTypeReference<List<String>>for parameterized types (preserves generic info).classfor simple types (no change to existing behavior)Before:
After:
This ensures Jackson can distinguish between
List<String>andList<Double>during deserialization, preventing multiple matches.Changes to already existing codebase
Test
The fix resolves the compilation failure in PR #3057's test: the ci run after having the current commit on top of the problematic branch is green