-
Notifications
You must be signed in to change notification settings - Fork 193
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
feat: add discriminatorOpenApi
tag to generate discriminator
schemas
#1572
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be an annotation or a config option? I feel the latter makes more sense so the consumer can decide, no?
hi @domoritz , i went with the annotation but it's different from the existing |
How can the consumer decide? |
here's an example:
The Bird schema is the traditional with |
Ah, by |
… open api discriminator
ok @domoritz please take a look at the latest commit, let me know if that's what you were thinking |
@@ -49,14 +49,16 @@ export function assertValidSchema( | |||
* @default {strict:false} | |||
*/ | |||
ajvOptions?: AjvOptions; | |||
} | |||
}, | |||
discriminatorType?: Config["discriminatorType"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should use an object for all these arguments now. This would remove the need for having so many undefined. Can you do that in a follow up pull request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi @domoritz yes, i was thinking the same thing... sure i'll submit one. thanks for merging
🚀 PR was released in |
Fixes #1551 and related to #1376 by @daanboer
This pr adds the ability to select a common property in a union type to act as an open-api discriminator. The discriminator tag is now supported by OpenAPI, Ajv, and other tools. The tag is not officially supported by json-schema... so there are 2 varieties:
discriminator
tag will generate anif-then-else
schema that complies with the json-schema specdiscriminatorOpenApi
tag will generate adiscriminator
schema that is supported by some tools but not compliant with json-schema.References:
Version
Published prerelease version:
v1.3.0-next.0
Changelog
🎉 This release contains work from new contributors! 🎉
Thanks for all your work!
❤️ Mario DeSousa (@mdesousa)
❤️ Grant Dickinson (@grant-d)
🚀 Enhancement
discriminatorOpenApi
tag to generatediscriminator
schemas #1572 (@mdesousa)🐛 Bug Fix
🔩 Dependency Updates
Authors: 6