Skip to content

Commit b4f18a5

Browse files
author
Sophia Marie Terry
committed
Update override for get/list to allow camelcase overrides
1 parent 9379954 commit b4f18a5

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

tools/spectral/ipa/rulesets/functions/IPA104ValidOperationID.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
} from './utils/collectionUtils.js';
77
import { hasException } from './utils/exceptions.js';
88
import { getResourcePathItems, isCustomMethodIdentifier } from './utils/resourceEvaluation.js';
9-
import { hasCustomMethodOverride, hasMethodVerbOverride } from './utils/extensions.js';
9+
import { hasCustomMethodOverride, hasMethodVerbOverride, VERB_OVERRIDE_EXTENSION } from './utils/extensions.js';
1010
import { isInvalidGetMethod } from './utils/methodLogic.js';
1111
import { validateOperationIdAndReturnErrors } from './utils/validations/validateOperationIdAndReturnErrors.js';
1212

@@ -32,6 +32,9 @@ export default (input, { methodName }, { path, documentInventory }) => {
3232
}
3333

3434
try {
35+
if (hasMethodVerbOverride(input, methodName)) {
36+
methodName = input[VERB_OVERRIDE_EXTENSION].verb;
37+
}
3538
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path);
3639

3740
if (errors.length > 0) {

tools/spectral/ipa/rulesets/functions/IPA105ValidOperationID.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {
77
} from './utils/collectionUtils.js';
88
import { getResourcePathItems, isCustomMethodIdentifier } from './utils/resourceEvaluation.js';
99
import { isInvalidListMethod } from './utils/methodLogic.js';
10-
import { hasCustomMethodOverride, hasMethodVerbOverride } from './utils/extensions.js';
10+
import { hasCustomMethodOverride, hasMethodVerbOverride, VERB_OVERRIDE_EXTENSION } from './utils/extensions.js';
1111
import { validateOperationIdAndReturnErrors } from './utils/validations/validateOperationIdAndReturnErrors.js';
1212

1313
const RULE_NAME = 'xgen-IPA-105-valid-operation-id';
@@ -31,6 +31,10 @@ export default (input, { methodName }, { path, documentInventory }) => {
3131
return;
3232
}
3333

34+
if (hasMethodVerbOverride(input, methodName)) {
35+
methodName = input[VERB_OVERRIDE_EXTENSION].verb;
36+
}
37+
3438
try {
3539
const errors = validateOperationIdAndReturnErrors(methodName, resourcePath, input, path);
3640

tools/spectral/ipa/rulesets/functions/utils/extensions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export function hasCustomMethodOverride(object) {
1919
* @returns {boolean} true if the object has the extension with the given verb, otherwise false
2020
*/
2121
export function hasMethodVerbOverride(object, verb) {
22-
return hasVerbOverride(object) && object[VERB_OVERRIDE_EXTENSION].verb === verb;
22+
return hasVerbOverride(object) && object[VERB_OVERRIDE_EXTENSION].verb.startsWith(verb);
2323
}
2424

2525
/**

0 commit comments

Comments
 (0)