-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP 306294: Add x-xgen-method-verb-override extension logic #817
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
for (let i = 0; i < keys.length; i++) { | ||
if (hasVerbOverride(endpoint[keys[i]])) { | ||
return true; | ||
} | ||
} |
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.
for (let i = 0; i < keys.length; i++) { | |
if (hasVerbOverride(endpoint[keys[i]])) { | |
return true; | |
} | |
} | |
return keys.contains(VERB_OVERRIDE_EXTENSION) |
Could this work?
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.
Oo yes should do! Will add now
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.
This actually doesn't work because I'm trying to look for extensions in the children of the object. I should be able to make it cleaner with includes though
Co-authored-by: Lovisa Berggren <[email protected]>
Co-authored-by: Lovisa Berggren <[email protected]>
tools/spectral/ipa/rulesets/functions/IPA109ValidOperationID.js
Outdated
Show resolved
Hide resolved
let expectedOperationID = ''; | ||
if (isCustomMethodIdentifier(resourcePath)) { | ||
expectedOperationID = generateOperationID(getCustomMethodName(resourcePath), stripCustomMethodName(resourcePath)); |
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.
let expectedOperationID = ''; | |
if (isCustomMethodIdentifier(resourcePath)) { | |
expectedOperationID = generateOperationID(getCustomMethodName(resourcePath), stripCustomMethodName(resourcePath)); | |
if (isCustomMethodIdentifier(resourcePath)) { | |
const expectedOperationID = generateOperationID(getCustomMethodName(resourcePath), stripCustomMethodName(resourcePath)); |
Since you are only using expectedOperationID
in the scope of each if block, you can declare it within. the block itself and assign
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.
Same with errors
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.
Pushed a refactor, thank you!
Co-authored-by: Lovisa Berggren <[email protected]>
for (let i = 0; i < methods.length; i++) { | ||
let obj = input[methods[i]]; | ||
const operationId = obj.operationId; |
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.
for (let i = 0; i < methods.length; i++) { | |
let obj = input[methods[i]]; | |
const operationId = obj.operationId; | |
methods.forEach((method) => { | |
const operationId = method.operationId | |
... | |
}) |
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.
Tip: JS has a lot of fun functions on Arrays, so that you rarely need to use for loops: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array 🚀
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 for addressing the comments, LGTM! 🚀
Added extension property x-xgen-method-verb-override so that legacy custom methods and endpoints with outlying design patterns can have their OperationIDs validated. This will prevent us from having to use exceptions, which makes downstream parsing of OperationIDs more difficult.
The extension includes a verb property that is used in place of the standard method verb and a customMethod boolean that indicates if a method should be validated as part of IPA 109.
This extension will be added to the endpoints listed as anticipated corrections in MMS as part of CLOUDP-331138.
Tests for the extension logic will be added when OperationID Validation rules and tests are enabled (CLOUDP-329722)
Jira ticket: CLOUDP-306294