Skip to content

Conversation

lovisaberggren
Copy link
Collaborator

@lovisaberggren lovisaberggren commented Jul 24, 2025

Proposed changes

Jira ticket: CLOUDP-331821

Adding support for operation ID override validation. Errors are returned when:

  • Operation ID is too long and there is no op ID override
  • Operation ID is good length but there is also an op ID override
  • When the op ID override is invalid:
    • Override is too long
    • Override doesn't start or end with expected words, and contains words not present in the long op ID

Additional changes

Moved the operation ID validation logic to a shared validation function called by each rule.

Added try catches to each rule in case of spectral errors.

Refactored custom method rule approach to apply to each operation instead of each path in the OAS.

Testing

Added unit tests for each introduced function.

Follow-ups

The rules are not yet enabled. This will be done with E2E testing in a later ticket.

};

describe('tools/spectral/ipa/rulesets/functions/utils/extensions.js', () => {
describe('hasMethodWithVerbOverride', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactored custom method rule approach to apply to each operation instead of each path in the OAS.

This method not needed, removed test

expect(generateOperationID('update', '/groups/{groupId}/clusters/{clusterName}')).toEqual('updateGroupCluster');
expect(generateOperationID('pause', '/groups/{groupId}/clusters/{clusterName}')).toEqual('pauseGroupCluster');
});
describe('generateOperationID', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added a describe to wrap these as part of generateOperationID function

* @param endpoint the endpoint to evaluate
* @returns {boolean} true if the endpoint has a nested method with the extension, otherwise false
*/
export function hasMethodWithVerbOverride(endpoint) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactored custom method rule approach to apply to each operation instead of each path in the OAS.

This method not needed anymore

@lovisaberggren lovisaberggren marked this pull request as ready for review July 24, 2025 15:54
@lovisaberggren lovisaberggren requested a review from a team as a code owner July 24, 2025 15:54
Copy link
Contributor

@sphterry sphterry 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 706adff into main Jul 25, 2025
8 checks passed
@lovisaberggren lovisaberggren deleted the CLOUDP-331821 branch July 25, 2025 09:07
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