Skip to content

Conversation

@wtrocki
Copy link
Member

@wtrocki wtrocki commented Mar 19, 2025

Proposed changes

Enforce Discriminator when oneOf is present.

Jira ticket: CLOUDP-306580

wtrocki added 2 commits March 19, 2025 19:41
… “discriminator” property defining when the exact type will be used.
@wtrocki wtrocki requested a review from a team as a code owner March 19, 2025 18:43
@wtrocki wtrocki changed the title CLOUDP-306580: IPA 125 - Each oneOf property must be accompanied CLOUDP-306580: IPA 125 - Each oneOf property must be accompanied with discriminator Mar 19, 2025
}

// Validate the presence of a discriminator
if (!schema.discriminator || typeof schema.discriminator !== 'object' || !schema.discriminator.propertyName) {
Copy link
Collaborator

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

const doc = testCase.document instanceof Document ? testCase.document : JSON.stringify(testCase.document);
const errors = await s.run(doc);

if (testCase.errors.length !== errors.length) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Copy link
Collaborator

@yelizhenden-mdb yelizhenden-mdb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM

@wtrocki wtrocki merged commit 9dd553e into main Mar 20, 2025
7 checks passed
@wtrocki wtrocki deleted the CLOUDP-306580-oneOf branch March 20, 2025 12:31
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

Successfully merging this pull request may close these issues.

2 participants