Skip to content

Commit 873d603

Browse files
SamerJaser96dpopp07
authored andcommitted
change default for all case convention validations to error (#86)
This applies to the following rules: `param_name_case_convention`, `paths_case_convention`, `property_case_convention`, `enum_case_convention` The rule `snake_case_only` (in categories `paths` and `schemas`) is now set to `off` by default. They will be deprecated in a future release.
1 parent 78d8659 commit 873d603

File tree

6 files changed

+43
-39
lines changed

6 files changed

+43
-39
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ The default values for each rule are described below.
359359
| Rule | Default |
360360
| --------------------------- | --------|
361361
| no_parameter_description | error |
362-
| param_name_case_convention | warning, lower_snake_case |
362+
| param_name_case_convention | error, lower_snake_case |
363363
| invalid_type_format_pair | error |
364364
| content_type_parameter | error |
365365
| accept_type_parameter | error |
@@ -370,8 +370,8 @@ The default values for each rule are described below.
370370
| Rule | Default |
371371
| --------------------------- | ------- |
372372
| missing_path_parameter | error |
373-
| snake_case_only | warning |
374-
| paths_case_convention | off, lower_snake_case |
373+
| snake_case_only | off |
374+
| paths_case_convention | error, lower_snake_case |
375375

376376
##### responses
377377
| Rule | Default |
@@ -393,13 +393,13 @@ The default values for each rule are described below.
393393
| Rule | Default |
394394
| --------------------------- | ------- |
395395
| invalid_type_format_pair | error |
396-
| snake_case_only | warning |
396+
| snake_case_only | off |
397397
| no_schema_description | warning |
398398
| no_property_description | warning |
399399
| description_mentions_json | warning |
400400
| array_of_arrays | warning |
401-
| property_case_convention | off, lower_snake_case |
402-
| enum_case_convention | off, lower_snake_case |
401+
| property_case_convention | error, lower_snake_case |
402+
| enum_case_convention | error, lower_snake_case |
403403

404404
###### walker
405405
| Rule | Default |

src/.defaultsForValidator.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const defaults = {
3030
},
3131
'parameters': {
3232
'no_parameter_description': 'error',
33-
'param_name_case_convention': ['warning', 'lower_snake_case'],
33+
'param_name_case_convention': ['error', 'lower_snake_case'],
3434
'invalid_type_format_pair': 'error',
3535
'content_type_parameter': 'error',
3636
'accept_type_parameter': 'error',
@@ -39,8 +39,8 @@ const defaults = {
3939
},
4040
'paths': {
4141
'missing_path_parameter': 'error',
42-
'snake_case_only': 'warning',
43-
'paths_case_convention': ['off', 'lower_snake_case']
42+
'snake_case_only': 'off',
43+
'paths_case_convention': ['error', 'lower_snake_case']
4444
},
4545
'responses': {
4646
'inline_response_schema': 'warning'
@@ -54,13 +54,13 @@ const defaults = {
5454
},
5555
'schemas': {
5656
'invalid_type_format_pair': 'error',
57-
'snake_case_only': 'warning',
57+
'snake_case_only': 'off',
5858
'no_schema_description': 'warning',
5959
'no_property_description': 'warning',
6060
'description_mentions_json': 'warning',
6161
'array_of_arrays': 'warning',
62-
'property_case_convention': [ 'off', 'lower_snake_case'],
63-
'enum_case_convention': [ 'off', 'lower_snake_case']
62+
'property_case_convention': [ 'error', 'lower_snake_case'],
63+
'enum_case_convention': [ 'error', 'lower_snake_case']
6464
},
6565
'walker': {
6666
'no_empty_descriptions': 'error',

test/cli-validator/tests/configFileValidator.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ describe('cli tool - test config file validator', function() {
296296
expect(res.invalid).toEqual(false);
297297
expect(capturedText.length).toEqual(0);
298298
expect(Array.isArray(status)).toEqual(true);
299-
expect(status[0]).not.toEqual(defaultStatus[0]);
299+
expect(status[0]).toEqual(defaultStatus[0]);
300300
expect(status[1]).toEqual(defaultStatus[1]);
301301
});
302302

test/cli-validator/tests/expectedOutput.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,21 @@ describe('cli tool - test expected output - Swagger 2', function() {
8787

8888
// .match(/\S+/g) returns an array of all non-whitespace strings
8989
// example output would be [ 'Line', ':', '59' ]
90+
91+
// errors
9092
expect(capturedText[4].match(/\S+/g)[2]).toEqual('31');
9193
expect(capturedText[8].match(/\S+/g)[2]).toEqual('54');
9294
expect(capturedText[12].match(/\S+/g)[2]).toEqual('59');
9395
expect(capturedText[16].match(/\S+/g)[2]).toEqual('108');
94-
expect(capturedText[21].match(/\S+/g)[2]).toEqual('36');
95-
expect(capturedText[25].match(/\S+/g)[2]).toEqual('59');
96-
expect(capturedText[29].match(/\S+/g)[2]).toEqual('197');
97-
expect(capturedText[33].match(/\S+/g)[2]).toEqual('108');
98-
expect(capturedText[37].match(/\S+/g)[2]).toEqual('131');
99-
expect(capturedText[41].match(/\S+/g)[2]).toEqual('134');
100-
expect(capturedText[45].match(/\S+/g)[2]).toEqual('172');
96+
expect(capturedText[20].match(/\S+/g)[2]).toEqual('172');
97+
98+
// warnings
99+
expect(capturedText[25].match(/\S+/g)[2]).toEqual('36');
100+
expect(capturedText[29].match(/\S+/g)[2]).toEqual('59');
101+
expect(capturedText[33].match(/\S+/g)[2]).toEqual('197');
102+
expect(capturedText[37].match(/\S+/g)[2]).toEqual('108');
103+
expect(capturedText[41].match(/\S+/g)[2]).toEqual('131');
104+
expect(capturedText[45].match(/\S+/g)[2]).toEqual('134');
101105
expect(capturedText[49].match(/\S+/g)[2]).toEqual('126');
102106
});
103107

test/cli-validator/tests/optionHandling.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -149,40 +149,40 @@ describe('cli tool - test option handling', function() {
149149
const statsSection = capturedText.findIndex(x => x.includes('statistics'));
150150

151151
// totals
152-
expect(capturedText[statsSection + 1].match(/\S+/g)[5]).toEqual('4');
153-
expect(capturedText[statsSection + 2].match(/\S+/g)[5]).toEqual('8');
152+
expect(capturedText[statsSection + 1].match(/\S+/g)[5]).toEqual('5');
153+
expect(capturedText[statsSection + 2].match(/\S+/g)[5]).toEqual('7');
154154

155155
// errors
156156
expect(capturedText[statsSection + 4].match(/\S+/g)[0]).toEqual('2');
157-
expect(capturedText[statsSection + 4].match(/\S+/g)[1]).toEqual('(50%)');
157+
expect(capturedText[statsSection + 4].match(/\S+/g)[1]).toEqual('(40%)');
158158

159159
expect(capturedText[statsSection + 5].match(/\S+/g)[0]).toEqual('1');
160-
expect(capturedText[statsSection + 5].match(/\S+/g)[1]).toEqual('(25%)');
160+
expect(capturedText[statsSection + 5].match(/\S+/g)[1]).toEqual('(20%)');
161161

162162
expect(capturedText[statsSection + 6].match(/\S+/g)[0]).toEqual('1');
163-
expect(capturedText[statsSection + 6].match(/\S+/g)[1]).toEqual('(25%)');
163+
expect(capturedText[statsSection + 6].match(/\S+/g)[1]).toEqual('(20%)');
164164

165-
// warnings
166-
expect(capturedText[statsSection + 9].match(/\S+/g)[0]).toEqual('2');
167-
expect(capturedText[statsSection + 9].match(/\S+/g)[1]).toEqual('(25%)');
165+
expect(capturedText[statsSection + 7].match(/\S+/g)[0]).toEqual('1');
166+
expect(capturedText[statsSection + 7].match(/\S+/g)[1]).toEqual('(20%)');
168167

169-
expect(capturedText[statsSection + 10].match(/\S+/g)[0]).toEqual('1');
170-
expect(capturedText[statsSection + 10].match(/\S+/g)[1]).toEqual('(13%)');
168+
// warnings
169+
expect(capturedText[statsSection + 10].match(/\S+/g)[0]).toEqual('2');
170+
expect(capturedText[statsSection + 10].match(/\S+/g)[1]).toEqual('(29%)');
171171

172172
expect(capturedText[statsSection + 11].match(/\S+/g)[0]).toEqual('1');
173-
expect(capturedText[statsSection + 11].match(/\S+/g)[1]).toEqual('(13%)');
173+
expect(capturedText[statsSection + 11].match(/\S+/g)[1]).toEqual('(14%)');
174174

175175
expect(capturedText[statsSection + 12].match(/\S+/g)[0]).toEqual('1');
176-
expect(capturedText[statsSection + 12].match(/\S+/g)[1]).toEqual('(13%)');
176+
expect(capturedText[statsSection + 12].match(/\S+/g)[1]).toEqual('(14%)');
177177

178178
expect(capturedText[statsSection + 13].match(/\S+/g)[0]).toEqual('1');
179-
expect(capturedText[statsSection + 13].match(/\S+/g)[1]).toEqual('(13%)');
179+
expect(capturedText[statsSection + 13].match(/\S+/g)[1]).toEqual('(14%)');
180180

181181
expect(capturedText[statsSection + 14].match(/\S+/g)[0]).toEqual('1');
182-
expect(capturedText[statsSection + 14].match(/\S+/g)[1]).toEqual('(13%)');
182+
expect(capturedText[statsSection + 14].match(/\S+/g)[1]).toEqual('(14%)');
183183

184184
expect(capturedText[statsSection + 15].match(/\S+/g)[0]).toEqual('1');
185-
expect(capturedText[statsSection + 15].match(/\S+/g)[1]).toEqual('(13%)');
185+
expect(capturedText[statsSection + 15].match(/\S+/g)[1]).toEqual('(14%)');
186186
});
187187

188188
it('should not print statistics report by default', async function() {

test/plugins/validation/2and3/parameters-ibm.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,16 @@ describe('validation plugin - semantic - parameters-ibm', () => {
5858
};
5959

6060
const res = validate({ jsSpec: spec }, config);
61-
expect(res.errors.length).toEqual(0);
62-
expect(res.warnings.length).toEqual(1);
63-
expect(res.warnings[0].path).toEqual([
61+
expect(res.errors.length).toEqual(1);
62+
expect(res.warnings.length).toEqual(0);
63+
expect(res.errors[0].path).toEqual([
6464
'paths',
6565
'/pets',
6666
'get',
6767
'parameters',
6868
'0'
6969
]);
70-
expect(res.warnings[0].message).toEqual(
70+
expect(res.errors[0].message).toEqual(
7171
'Parameter names must follow case convention: lower_snake_case'
7272
);
7373
});

0 commit comments

Comments
 (0)