You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When generating client code from an OpenAPI 3.0 specification using openapi-generator (version 7.13.0), the generator fails to generate or use the discriminator for polymorphic deserialization if:
Two or more subtypes define properties with the same name (e.g., both have a property called value or data).
The generator does not generate code that uses the discriminator for deserialization.
In Python, deserialization fails with a "multiple matches found" exception.
Suggest a fix
The generator should either emit a clear error/warning during generation or support discriminator-based deserialization as long as the discriminator property is present in the payload, regardless of duplicate property names.
At minimum, this limitation should be clearly documented.
Workaround
Ensure that all subtypes have at least one unique property name, or use the discriminator property with a unique value for each subtype.
The text was updated successfully, but these errors were encountered:
MaxHuber03
changed the title
[BUG] [Python] Discriminator Not Used for Subtypes in oneOf Array Response
[BUG] [Python] Discriminator Not Generated or Used When Subtypes Have Duplicate Property Names or No Unique Properties
May 28, 2025
Uh oh!
There was an error while loading. Please reload this page.
Description
When generating client code from an OpenAPI 3.0 specification using openapi-generator (version 7.13.0), the generator fails to generate or use the discriminator for polymorphic deserialization if:
openapi-generator version
7.13.0
OpenAPI declaration file content
This is a minimal example
Generation Details
In the config file I added:
"useOneOfDiscriminatorLookup": true,
Result
The generator does not generate code that uses the discriminator for deserialization.
In Python, deserialization fails with a "multiple matches found" exception.
Suggest a fix
The generator should either emit a clear error/warning during generation or support discriminator-based deserialization as long as the discriminator property is present in the payload, regardless of duplicate property names.
At minimum, this limitation should be clearly documented.
Workaround
Ensure that all subtypes have at least one unique property name, or use the discriminator property with a unique value for each subtype.
The text was updated successfully, but these errors were encountered: