Skip to content
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

Add 'discriminator' property on anyOf relations for use with openapi-generate #50

Closed
Tails opened this issue Jul 12, 2021 · 1 comment
Closed

Comments

@Tails
Copy link

Tails commented Jul 12, 2021

With the default settings, unions are rendered using the 'anyOf' relation, which is fine:

TreeModel:
      anyOf:
        - $ref: '#/components/schemas/ScoreTree'
        - $ref: '#/components/schemas/SongTree'
        - $ref: '#/components/schemas/PartTree'
        - ... etc

But when you want to use the OpenAPI generator to generate client code, the enum declaration needs (at least >= openapi-generator v5.0.0) a 'discriminator' property: https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/

This seems to correlate with serde's #[serde(tag = "type")] serialization option for enums.

Edit: seems to be more related to Schemars. Pre-existing issue: GREsau/schemars#39

@ralpha
Copy link
Collaborator

ralpha commented Jul 12, 2021

Yes this looks like Schemars need to fix this. If something needs fixing here, let me know or reopen this issue.
I'll close the issue here as this will be fixed in GREsau/schemars#39.

@ralpha ralpha closed this as completed Jul 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants