Skip to content

Commit 0867e2d

Browse files
address the comments
1 parent 9a7fc40 commit 0867e2d

File tree

3 files changed

+24
-11
lines changed

3 files changed

+24
-11
lines changed

tools/spectral/ipa/__tests__/eachCustomMethodMustUseCamelCase.test.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,33 +38,47 @@ testRule('xgen-IPA-109-custom-method-must-use-camel-case', [
3838
'/a:MethodName': {},
3939
'/a/{exampleId}:method_name': {},
4040
'/a:method_name': {},
41+
'/a/{exampleId}:': {},
42+
'/a:': {},
4143
},
4244
},
4345
errors: [
4446
{
4547
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
46-
message: 'The custom method must use camelCase format. http://go/ipa/109',
48+
message: 'The custom method name must use camelCase format. http://go/ipa/109',
4749
path: ['paths', '/a/{exampleId}:MethodName'],
4850
severity: DiagnosticSeverity.Warning,
4951
},
5052
{
5153
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
52-
message: 'The custom method must use camelCase format. http://go/ipa/109',
54+
message: 'The custom method name must use camelCase format. http://go/ipa/109',
5355
path: ['paths', '/a:MethodName'],
5456
severity: DiagnosticSeverity.Warning,
5557
},
5658
{
5759
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
58-
message: 'The custom method must use camelCase format. http://go/ipa/109',
60+
message: 'The custom method name must use camelCase format. http://go/ipa/109',
5961
path: ['paths', '/a/{exampleId}:method_name'],
6062
severity: DiagnosticSeverity.Warning,
6163
},
6264
{
6365
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
64-
message: 'The custom method must use camelCase format. http://go/ipa/109',
66+
message: 'The custom method name must use camelCase format. http://go/ipa/109',
6567
path: ['paths', '/a:method_name'],
6668
severity: DiagnosticSeverity.Warning,
6769
},
70+
{
71+
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
72+
message: 'The custom method name must use camelCase format. http://go/ipa/109',
73+
path: ['paths', '/a/{exampleId}:'],
74+
severity: DiagnosticSeverity.Warning,
75+
},
76+
{
77+
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
78+
message: 'The custom method name must use camelCase format. http://go/ipa/109',
79+
path: ['paths', '/a:'],
80+
severity: DiagnosticSeverity.Warning,
81+
},
6882
],
6983
},
7084
]);

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { getCustomMethod, isCustomMethod } from './utils/resourceEvaluation.js';
1+
import { getCustomMethodName, isCustomMethod } from './utils/resourceEvaluation.js';
22
import { hasException } from './utils/exceptions.js';
33
import { casing } from '@stoplight/spectral-functions';
44

55
const RULE_NAME = 'xgen-IPA-109-custom-method-must-use-camel-case';
6-
const ERROR_MESSAGE = 'The custom method must use camelCase format.';
6+
const ERROR_MESSAGE = 'The custom method name must use camelCase format.';
77
const ERROR_RESULT = [{ message: ERROR_MESSAGE }];
88

99
export default (input, opts, { path }) => {
@@ -16,9 +16,9 @@ export default (input, opts, { path }) => {
1616
return;
1717
}
1818

19-
let methodName = getCustomMethod(pathKey);
19+
let methodName = getCustomMethodName(pathKey);
2020
if (!methodName) {
21-
return;
21+
return ERROR_RESULT;
2222
}
2323

2424
const isCamelCase = casing(methodName, { type: 'camel', disallowDigits: true });

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ export function isCustomMethod(path) {
66
return path.includes(':');
77
}
88

9-
export function getCustomMethod(path) {
10-
const [, methodName] = path.split(':');
11-
return methodName;
9+
export function getCustomMethodName(path) {
10+
return path.split(':')[1];
1211
}
1312

1413
/**

0 commit comments

Comments
 (0)