Skip to content

Support discriminator for polymorphic types and support oneOf #219

Description

@bowenwr

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.

Activity

  1. dbanty commented on Nov 14, 2020

    @dbanty
    Collaborator

    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.

  2. locked and limited conversation to collaborators on Aug 13, 2023
  3. converted this issue into a discussion #830 on Aug 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions