Skip to content

Commit f2d9ca7

Browse files
fix
1 parent dfd791f commit f2d9ca7

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ import { casing } from '@stoplight/spectral-functions';
55
const RULE_NAME = 'xgen-IPA-123-enum-values-must-be-upper-snake-case';
66
const ERROR_MESSAGE = 'enum value must be UPPER_SNAKE_CASE.';
77

8-
export function getSchemaPathFromEnumPath(path) {
9-
if (path.includes('items')) {
10-
path = path.slice(0, -1);
8+
function getSchemaPathFromEnumPath(path) {
9+
const enumIndex = path.lastIndexOf('enum');
10+
if (path[enumIndex - 1] === 'items') {
11+
return path.slice(0, enumIndex - 1);
1112
}
12-
return path.slice(0, -1);
13+
return path.slice(0, enumIndex);
1314
}
1415

1516
export default (input, _, { path, documentInventory }) => {

0 commit comments

Comments
 (0)