Skip to content

Commit 9ae2c93

Browse files
author
Sophia Marie Terry
committed
Edit logic to handle outliers
1 parent d3deaae commit 9ae2c93

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ const CAMEL_CASE = /[A-Z]?[a-z]+/g;
1010
* @param path the path for the endpoint
1111
*/
1212
export function generateOperationID(method, path) {
13+
if (!path) {
14+
return method;
15+
}
16+
1317
let resourceIdentifier = removePrefix(path);
1418
if (resourceIdentifier.includes('.')) {
1519
resourceIdentifier = resourceIdentifier.substring(0, resourceIdentifier.lastIndexOf('.'));
@@ -37,7 +41,11 @@ export function generateOperationID(method, path) {
3741
}
3842

3943
// singularize final noun, dependent on resource identifier
40-
if (isSingleResourceIdentifier(resourceIdentifier) || verb === 'create') {
44+
if (
45+
isPathParam(resourceIdentifier.split('/').pop()) ||
46+
isSingleResourceIdentifier(resourceIdentifier) ||
47+
verb === 'create'
48+
) {
4149
nouns[nouns.length - 1] = inflection.singularize(nouns[nouns.length - 1]);
4250
}
4351

0 commit comments

Comments
 (0)