Skip to content

Commit fcf03ca

Browse files
fix: exception level
1 parent e72e2d5 commit fcf03ca

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,31 +89,31 @@ testRule('xgen-IPA-125-oneOf-must-accompany-oneOf-anyOf-allOf', [
8989
Schema: {
9090
discriminator: {
9191
propertyName: 'type',
92-
'x-xgen-IPA-exception': {
93-
'xgen-IPA-125-oneOf-must-accompany-oneOf-anyOf-allOf': 'reason',
94-
},
9592
},
9693
properties: {
9794
type: {
9895
type: 'string',
9996
},
10097
},
98+
'x-xgen-IPA-exception': {
99+
'xgen-IPA-125-oneOf-must-accompany-oneOf-anyOf-allOf': 'reason',
100+
},
101101
},
102102
NestedSchema: {
103103
properties: {
104104
name: {
105105
type: 'object',
106106
discriminator: {
107107
propertyName: 'first',
108-
'x-xgen-IPA-exception': {
109-
'xgen-IPA-125-oneOf-must-accompany-oneOf-anyOf-allOf': 'reason',
110-
},
111108
},
112109
properties: {
113110
first: {
114111
type: 'string',
115112
},
116113
},
114+
'x-xgen-IPA-exception': {
115+
'xgen-IPA-125-oneOf-must-accompany-oneOf-anyOf-allOf': 'reason',
116+
},
117117
},
118118
address: {
119119
type: 'string',

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ 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 errors = checkViolationsAndReturnErrors(input, path, documentInventory.resolved);
8-
return evaluateAndCollectAdoptionStatus(errors, rule.name, input, path);
9-
};
7+
const siblings = resolveObject(documentInventory.resolved, path.slice(0, path.length - 1));
108

11-
function checkViolationsAndReturnErrors(input, path, oas) {
12-
const siblings = Object.keys(resolveObject(oas, path.slice(0, path.length - 1)));
9+
const errors = checkViolationsAndReturnErrors(input, path, Object.keys(siblings));
10+
return evaluateAndCollectAdoptionStatus(errors, rule.name, siblings, path);
11+
};
1312

14-
if (!siblings.includes('oneOf') && !siblings.includes('anyOf') && !siblings.includes('allOf')) {
13+
function checkViolationsAndReturnErrors(input, path, siblingKeys) {
14+
if (!siblingKeys.includes('oneOf') && !siblingKeys.includes('anyOf') && !siblingKeys.includes('allOf')) {
1515
return [
1616
{
1717
path,

0 commit comments

Comments
 (0)