openapi-python-client
openapi-python-client copied to clipboard
Support discriminator for polymorphic types and support oneOf
Is your feature request related to a problem? Please describe.
When an endpoint returns oneOf several different classes, currently it returns an empty object. Sample component snippet:
ReturnedObject:
oneOf:
- $ref: '#/components/schemas/PolymorphicType'
- $ref: '#/components/schemas/AnotherPolymorphicType'
Describe the solution you'd like
Support discriminators to be able to deserialize polymorphic types.
I tested this with the latest code on main (roughly 0.7.0-rc.1) and it does attempt to generate proper responses now using the same code it would for unions inside a model (basically a series of try/except). So it's better than nothing, though for sure we still should add discriminators in a future version.