Skip to content

Commit d23d11c

Browse files
fix: metric path
1 parent e048cf3 commit d23d11c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ testRule('xgen-IPA-125-discriminator-must-accompany-oneOf-anyOf-allOf', [
7070
{
7171
code: 'xgen-IPA-125-discriminator-must-accompany-oneOf-anyOf-allOf',
7272
message: "Each discriminator property must be accompanied by a 'oneOf', 'anyOf' or 'allOf' property.",
73-
path: ['components', 'schemas', 'Schema', 'discriminator'],
73+
path: ['components', 'schemas', 'Schema'],
7474
severity: DiagnosticSeverity.Warning,
7575
},
7676
{
7777
code: 'xgen-IPA-125-discriminator-must-accompany-oneOf-anyOf-allOf',
7878
message: "Each discriminator property must be accompanied by a 'oneOf', 'anyOf' or 'allOf' property.",
79-
path: ['components', 'schemas', 'NestedSchema', 'properties', 'name', 'discriminator'],
79+
path: ['components', 'schemas', 'NestedSchema', 'properties', 'name'],
8080
severity: DiagnosticSeverity.Warning,
8181
},
8282
],

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import { resolveObject } from './utils/componentUtils.js';
44
const ERROR_MESSAGE = "Each discriminator property must be accompanied by a 'oneOf', 'anyOf' or 'allOf' property.";
55

66
export default (input, _, { path, documentInventory, rule }) => {
7-
const siblings = resolveObject(documentInventory.resolved, path.slice(0, path.length - 1));
7+
const siblingPath = path.slice(0, path.length - 1);
8+
const siblings = resolveObject(documentInventory.resolved, siblingPath);
89

9-
const errors = checkViolationsAndReturnErrors(input, path, Object.keys(siblings));
10-
return evaluateAndCollectAdoptionStatus(errors, rule.name, siblings, path);
10+
const errors = checkViolationsAndReturnErrors(input, siblingPath, Object.keys(siblings));
11+
return evaluateAndCollectAdoptionStatus(errors, rule.name, siblings, siblingPath);
1112
};
1213

1314
function checkViolationsAndReturnErrors(input, path, siblingKeys) {

0 commit comments

Comments
 (0)