Skip to content

Commit 794456c

Browse files
author
Sophia Marie Terry
committed
CLOUDP-306294: updated utilities to handle get/list edge cases
1 parent e00ebcf commit 794456c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import { isSingleResourceIdentifier, isResourceCollectionIdentifier, isSingletonResource } from './resourceEvaluation';
1+
import { isResourceCollectionIdentifier, isSingletonResource } from './resourceEvaluation';
2+
import { isPathParam } from './resourceEvaluation';
23

34
export function invalidGetMethod(resourcePath, resourcePaths) {
45
return (
5-
!isSingleResourceIdentifier(resourcePath) &&
6+
!isPathParam(resourcePath.split('/').pop()) &&
67
!(isResourceCollectionIdentifier(resourcePath) && isSingletonResource(resourcePaths))
78
);
89
}
910

1011
export function invalidListMethod(resourcePath, resourcePaths) {
11-
return !isResourceCollectionIdentifier(resourcePath) || isSingletonResource(resourcePaths);
12+
return isPathParam(resourcePath.split('/').pop()) || isSingletonResource(resourcePaths);
1213
}

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const CAMEL_CASE = /[A-Z]?[a-z]+/g;
1111
*/
1212
export function generateOperationID(method, path) {
1313
let resourceIdentifier = removePrefix(path);
14+
if (resourceIdentifier.includes('.')) {
15+
resourceIdentifier = resourceIdentifier.substring(0, resourceIdentifier.lastIndexOf('.'));
16+
}
17+
1418
let nouns = resourceIdentifier.split('/').filter((section) => section.length > 0 && !isPathParam(section));
1519

1620
// legacy custom method - use end of path as custom method name

0 commit comments

Comments
 (0)