Skip to content

feat(ipa): New rule xgen-IPA-125-oneOf-schema-property-same-type #873

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

Merged
merged 4 commits into from
Aug 14, 2025

Conversation

lovisaberggren
Copy link
Collaborator

@lovisaberggren lovisaberggren commented Aug 7, 2025

Proposed changes

Adds new warning-level rule checking that properties with the same name in oneOf schemas are of the same type.

If the property is a base type, it should have the same type is all oneOf schemas. If the property is of object type, it should have the same schema in all oneOf schemas.

Current violations:

warning  xgen-IPA-125-oneOf-schema-property-same-type  Property 'metricThreshold' has different types or schemas in oneOf items. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-125-oneOf-schema-property-same-type  components.schemas.GroupAlertsConfig.oneOf
warning  xgen-IPA-125-oneOf-schema-property-same-type  Property 'threshold' has different types or schemas in oneOf items. https://mdb.link/mongodb-atlas-openapi-validation#xgen-IPA-125-oneOf-schema-property-same-type        components.schemas.GroupAlertsConfig.oneOf

Jira ticket: CLOUDP-309117

@lovisaberggren lovisaberggren marked this pull request as ready for review August 14, 2025 10:04
@lovisaberggren lovisaberggren requested a review from a team as a code owner August 14, 2025 10:04
},
},
],
'x-xgen-IPA-exception': {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Q: If the exception is defined at the schema level (via Swagger annotations), should the tracked path for exceptions also point to the schemas?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure I understand the question, could you clarify? Do you mean the path passed to the metrics?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I’m trying to confirm whether the path passed to metrics should be the schema path where the exception is defined, or if we’re instead passing the oneOf path

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes the exception path is to oneOf. Since the adoption and violation are on the oneof path, it makes sense for the exception to be on the same path as well. Also, exceptions cannot be on the oneOf object, so therefore it's on the schema level

Copy link
Collaborator

Choose a reason for hiding this comment

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

So my suggestion is that we can collect adoption status on schema level instead of oneOf level, because the exception is also defined on the schema level. What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sure, 👍

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.

LGTM, thanks!

@lovisaberggren lovisaberggren merged commit 21b84d9 into main Aug 14, 2025
12 checks passed
@lovisaberggren lovisaberggren deleted the CLOUDP-309117 branch August 14, 2025 13:02
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