Skip to content

[Python] Multilevel inheritance discriminator support #4912

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
5 of 6 tasks
eak24 opened this issue Jan 2, 2020 · 2 comments · Fixed by #6124 or #5809
Closed
5 of 6 tasks

[Python] Multilevel inheritance discriminator support #4912

eak24 opened this issue Jan 2, 2020 · 2 comments · Fixed by #6124 or #5809

Comments

@eak24
Copy link
Contributor

eak24 commented Jan 2, 2020

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used? 4.2.3
  • Have you search for related issues/PRs? Yes - they are [Python] Adds allOf/oneOf/anyOf composed models #4446
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

@spacether

When using OAS to describe a complex polymorphic graph, the client is currently unable to serialize grandchildren of any given type (subclasses of subclasses.) I have made a recursive model lookup function, which recursively looks at the discriminators of the subclasses (discriminated classes) until the leaf nodes, but that has very bad performance, reducing performance to 1/100 of normal deserialization. There is a lot of repeated work done for the same model over and over, so I added caching, and the performance is now roughly 1/10 of what it was. Ideally, there would be some way to specify the whole type mapping dictionary.

openapi-generator version

4.2.3

OpenAPI declaration file content or url
components:
  schemas:
    Animal:
      type: object
      required:
      - type_key
      properties:
        type_key:
          type: string
      mapping:
        pet: '#/components/schemas/Pet'
    Pet:
      type: object
      properties:
        type_key:
          type: string
      discriminator:
        propertyName: type_key
        mapping:
          cat: '#/components/schemas/Cat'
    Cat:
      type: object
      properties:
        type_key:
          age: number
Suggest a fix

See Description

@spacether
Copy link
Contributor

spacether commented Jan 2, 2020

Can you please submit your prosed PR from eak24@f606cfb
As a fix for this issue?

@eak24
Copy link
Contributor Author

eak24 commented Jan 2, 2020

@spacether, #4913 is submitted as a PR - still nowhere close to final, it isn't performant for my use case, so I'd like some advice on how to improve that and whether or not this is inline with the OAS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment