Skip to content

Commit b609965

Browse files
address the comments
1 parent 8c5de56 commit b609965

File tree

1 file changed

+65
-2
lines changed

1 file changed

+65
-2
lines changed

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

Lines changed: 65 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ testRule('xgen-IPA-118-no-additional-properties-false', [
5858
{
5959
name: 'invalid with additionalProperties: false',
6060
document: {
61-
openapi: '3.0.0',
6261
components: {
6362
schemas: {
6463
ExampleSchema: {
@@ -118,7 +117,45 @@ testRule('xgen-IPA-118-no-additional-properties-false', [
118117
],
119118
},
120119
{
121-
name: 'with exception tag',
120+
name: 'invalid with multiple nested additionalProperties: false',
121+
document: {
122+
components: {
123+
schemas: {
124+
ParentSchema: {
125+
type: 'object',
126+
properties: {
127+
child: {
128+
type: 'object',
129+
properties: {
130+
name: { type: 'string' },
131+
},
132+
additionalProperties: false,
133+
},
134+
},
135+
additionalProperties: false,
136+
},
137+
},
138+
},
139+
},
140+
errors: [
141+
{
142+
code: 'xgen-IPA-118-no-additional-properties-false',
143+
message:
144+
"Schema must not use 'additionalProperties: false'. Consider using 'additionalProperties: true' or omitting the property.",
145+
path: ['components', 'schemas', 'ParentSchema'],
146+
severity: DiagnosticSeverity.Warning,
147+
},
148+
{
149+
code: 'xgen-IPA-118-no-additional-properties-false',
150+
message:
151+
"Schema must not use 'additionalProperties: false'. Consider using 'additionalProperties: true' or omitting the property.",
152+
path: ['components', 'schemas', 'ParentSchema', 'properties', 'child'],
153+
severity: DiagnosticSeverity.Warning,
154+
},
155+
],
156+
},
157+
{
158+
name: 'with exception',
122159
document: {
123160
components: {
124161
schemas: {
@@ -152,4 +189,30 @@ testRule('xgen-IPA-118-no-additional-properties-false', [
152189
},
153190
errors: [],
154191
},
192+
{
193+
name: 'invalid with multiple nested additionalProperties: false - exceptions',
194+
document: {
195+
components: {
196+
schemas: {
197+
ParentSchema: {
198+
type: 'object',
199+
properties: {
200+
child: {
201+
type: 'object',
202+
properties: {
203+
name: { type: 'string' },
204+
},
205+
additionalProperties: false,
206+
},
207+
},
208+
additionalProperties: false,
209+
'x-xgen-IPA-exception': {
210+
'xgen-IPA-118-no-additional-properties-false': 'Exception reason',
211+
},
212+
},
213+
},
214+
},
215+
},
216+
errors: [],
217+
},
155218
]);

0 commit comments

Comments
 (0)