-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP-306580: IPA 125 - Each oneOf property must be accompanied with discriminator #572
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
Conversation
… “discriminator” property defining when the exact type will be used.
tools/spectral/ipa/rulesets/functions/IPA125OneOfMustHaveDiscriminator.js
Outdated
Show resolved
Hide resolved
| } | ||
|
|
||
| // Validate the presence of a discriminator | ||
| if (!schema.discriminator || typeof schema.discriminator !== 'object' || !schema.discriminator.propertyName) { |
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.
[Nit] line 29-47 can be included in checkViolationsAndReturnErrors function
tools/spectral/ipa/rulesets/functions/IPA125OneOfMustHaveDiscriminator.js
Outdated
Show resolved
Hide resolved
| const doc = testCase.document instanceof Document ? testCase.document : JSON.stringify(testCase.document); | ||
| const errors = await s.run(doc); | ||
|
|
||
| if (testCase.errors.length !== errors.length) { |
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.
❤️
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.
Thanks! LGTM
Proposed changes
Enforce Discriminator when oneOf is present.
Jira ticket: CLOUDP-306580