Skip to content

Commit 619c8c6

Browse files
address the comments
1 parent 297c81e commit 619c8c6

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,43 @@ testRule('xgen-IPA-109-custom-method-must-use-camel-case', [
3939
'/a/{exampleId}:method_name': {},
4040
'/a:method_name': {},
4141
'/a/{exampleId}:': {},
42-
'/a:': {},
42+
'/a:': {}
4343
},
4444
},
4545
errors: [
4646
{
4747
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
48-
message: 'The custom method name must use camelCase format. http://go/ipa/109',
48+
message: 'The custom method name must use camelCase format. Method name: MethodName. http://go/ipa/109',
4949
path: ['paths', '/a/{exampleId}:MethodName'],
5050
severity: DiagnosticSeverity.Warning,
5151
},
5252
{
5353
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
54-
message: 'The custom method name must use camelCase format. http://go/ipa/109',
54+
message: 'The custom method name must use camelCase format. Method name: MethodName. http://go/ipa/109',
5555
path: ['paths', '/a:MethodName'],
5656
severity: DiagnosticSeverity.Warning,
5757
},
5858
{
5959
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
60-
message: 'The custom method name must use camelCase format. http://go/ipa/109',
60+
message: 'The custom method name must use camelCase format. Method name: method_name. http://go/ipa/109',
6161
path: ['paths', '/a/{exampleId}:method_name'],
6262
severity: DiagnosticSeverity.Warning,
6363
},
6464
{
6565
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
66-
message: 'The custom method name must use camelCase format. http://go/ipa/109',
66+
message: 'The custom method name must use camelCase format. Method name: method_name. http://go/ipa/109',
6767
path: ['paths', '/a:method_name'],
6868
severity: DiagnosticSeverity.Warning,
6969
},
7070
{
7171
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
72-
message: 'The custom method name must use camelCase format. http://go/ipa/109',
72+
message: 'Custom method name cannot be empty or blank. http://go/ipa/109',
7373
path: ['paths', '/a/{exampleId}:'],
7474
severity: DiagnosticSeverity.Warning,
7575
},
7676
{
7777
code: 'xgen-IPA-109-custom-method-must-use-camel-case',
78-
message: 'The custom method name must use camelCase format. http://go/ipa/109',
78+
message: 'Custom method name cannot be empty or blank. http://go/ipa/109',
7979
path: ['paths', '/a:'],
8080
severity: DiagnosticSeverity.Warning,
8181
},

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { casing } from '@stoplight/spectral-functions';
44

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

99
export default (input, opts, { path }) => {
1010
// Extract the path key (e.g., '/a/{exampleId}:method') from the JSONPath.
@@ -17,12 +17,12 @@ export default (input, opts, { path }) => {
1717
}
1818

1919
let methodName = getCustomMethodName(pathKey);
20-
if (!methodName) {
21-
return ERROR_RESULT;
20+
if (methodName.length === 0 || methodName.trim().length === 0) {
21+
return [{ message: "Custom method name cannot be empty or blank." }];
2222
}
2323

2424
const isCamelCase = casing(methodName, { type: 'camel', disallowDigits: true });
2525
if (isCamelCase) {
26-
return ERROR_RESULT;
26+
return [{ message: `${ERROR_MESSAGE} Method name: ${methodName}.` }];
2727
}
2828
};

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ export function isPathParam(str) {
1111
const pathParamRegEx = new RegExp(`^{[a-z][a-zA-Z0-9]*}$`);
1212
const pathParamWithCustomMethodRegEx = new RegExp(`^{[a-z][a-zA-Z0-9]*}:[a-z][a-zA-Z0-9]*$`);
1313
return pathParamRegEx.test(str) || pathParamWithCustomMethodRegEx.test(str);
14-
}
14+
}

0 commit comments

Comments
 (0)