Skip to content

Conversation

@lovisaberggren
Copy link
Collaborator

Proposed changes

Adds rule xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object and also refactor to use a common validation function for all suffix related rules.

Jira ticket: CLOUDP-304943

@lovisaberggren lovisaberggren marked this pull request as ready for review March 19, 2025 14:22
@lovisaberggren lovisaberggren requested a review from a team as a code owner March 19, 2025 14:22
@wtrocki wtrocki marked this pull request as draft March 19, 2025 14:44
@lovisaberggren lovisaberggren marked this pull request as ready for review March 19, 2025 14:54
* @param {string} ruleName the rule name
* @returns {[{path, message: string}]} the errors found, or an empty array in case of no errors
*/
export function checkSchemaRefSuffixAndReturnErrors(path, contentPerMediaType, expectedSuffix, ruleName) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

To keep things consistent, I think we should keep the checkViolationsAndReturnErrors function and call these helper functions within its try-catch block. I also noticed another similar function: checkResponseCodeAndReturnErrors.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'd generally prefer to not have functions that basically only call another function. But if you have a strong opinion of always having the checkViolationsAndReturnErrors I can update all current rules in a follow-up

Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand your concern. I think it is fine, we keep the naming convention similar at least, and it is a kind of best-practice suggestion. No need for update. Thanks!

#### xgen-IPA-107-update-method-request-body-is-update-request-suffixed-object

![warn](https://img.shields.io/badge/warning-yellow)
The Update method request should be a `UpdateRequest` suffixed object.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: This description reads strangely.

Suggested change
The Update method request should be a `UpdateRequest` suffixed object.
The Update operation request body should reference model with `UpdateRequest` suffix.

Rule checks for the following conditions:
- Applies to PUT/PATCH methods on single resource paths and singleton resources
- Applies only to JSON content types
- Validation only applies to schema references to a predefined schema (not inline)
Copy link
Member

Choose a reason for hiding this comment

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

Unrelated: Would we have linting to prevent inline schemas (we do not have IPA for that)

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 if we expect all json schemas to have schema refs, or if there are issues with allowing inline schemas

Copy link
Member

Choose a reason for hiding this comment

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

SGTM. There are issues relevant to the code gen tools. Will take this offline. Thank you for confirming

Copy link
Member

@wtrocki wtrocki left a comment

Choose a reason for hiding this comment

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

LGTM

@lovisaberggren lovisaberggren merged commit 86096a7 into main Mar 19, 2025
8 checks passed
@lovisaberggren lovisaberggren deleted the CLOUDP-304943 branch March 19, 2025 16:01
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.

3 participants