Skip to content

Commit 35c3f29

Browse files
enum index fix
1 parent a5d137e commit 35c3f29

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ testRule('xgen-IPA-123-enum-values-must-be-upper-snake-case', [
6161
{
6262
code: 'xgen-IPA-123-enum-values-must-be-upper-snake-case',
6363
message: 'exampleA enum value must be UPPER_SNAKE_CASE. http://go/ipa/123',
64-
path: ['components', 'schemas', 'SchemaName', 'properties', 'exampleProperty', 'enum'],
64+
path: ['components', 'schemas', 'SchemaName', 'properties', 'exampleProperty', 'enum', '0'],
6565
severity: DiagnosticSeverity.Warning,
6666
},
6767
{
6868
code: 'xgen-IPA-123-enum-values-must-be-upper-snake-case',
6969
message: 'exampleB enum value must be UPPER_SNAKE_CASE. http://go/ipa/123',
70-
path: ['components', 'schemas', 'SchemaName', 'properties', 'exampleProperty', 'enum'],
70+
path: ['components', 'schemas', 'SchemaName', 'properties', 'exampleProperty', 'enum', '1'],
7171
severity: DiagnosticSeverity.Warning,
7272
},
7373
],
@@ -137,13 +137,13 @@ testRule('xgen-IPA-123-enum-values-must-be-upper-snake-case', [
137137
{
138138
code: 'xgen-IPA-123-enum-values-must-be-upper-snake-case',
139139
message: 'exampleA enum value must be UPPER_SNAKE_CASE. http://go/ipa/123',
140-
path: ['paths', '/a/{exampleId}', 'get', 'parameters', '0', 'schema', 'enum'],
140+
path: ['paths', '/a/{exampleId}', 'get', 'parameters', '0', 'schema', 'enum', '0'],
141141
severity: DiagnosticSeverity.Warning,
142142
},
143143
{
144144
code: 'xgen-IPA-123-enum-values-must-be-upper-snake-case',
145145
message: 'exampleB enum value must be UPPER_SNAKE_CASE. http://go/ipa/123',
146-
path: ['paths', '/a/{exampleId}', 'get', 'parameters', '0', 'schema', 'enum'],
146+
path: ['paths', '/a/{exampleId}', 'get', 'parameters', '0', 'schema', 'enum', '1'],
147147
severity: DiagnosticSeverity.Warning,
148148
},
149149
],

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ export default (input, _, { path, documentInventory }) => {
1414
}
1515

1616
const errors = [];
17-
for (const enumValue of input) {
17+
input.forEach((enumValue, index) => {
1818
const isUpperSnakeCase = casing(enumValue, { type: 'macro' });
1919

2020
if (isUpperSnakeCase) {
2121
errors.push({
22+
path: [...path, index],
2223
message: `${enumValue} ${ERROR_MESSAGE} `,
23-
path: path.concat(enumValue),
2424
});
2525
}
26-
}
26+
});
2727

2828
return errors;
2929
};

0 commit comments

Comments
 (0)