Skip to content

Commit 57001d2

Browse files
committed
[294] Add tests for "additionalProperties" and "additionalItems"
Ensure they stay same-object only.
1 parent 2719210 commit 57001d2

10 files changed

+153
-5
lines changed

tests/draft2019-09/additionalItems.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,38 @@
9393
"valid": true
9494
}
9595
]
96+
},
97+
{
98+
"description": "additionalItems should not look in applicators, valid case",
99+
"schema": {
100+
"allOf": [
101+
{ "items": [ { "type": "integer" } ] }
102+
],
103+
"additionalItems": { "type": "boolean" }
104+
},
105+
"tests": [
106+
{
107+
"description": "items defined in allOf are not examined",
108+
"data": [ 1, null ],
109+
"valid": true
110+
}
111+
]
112+
},
113+
{
114+
"description": "additionalItems should not look in applicators, invalid case",
115+
"schema": {
116+
"allOf": [
117+
{ "items": [ { "type": "integer" }, { "type": "string" } ] }
118+
],
119+
"items": [ {"type": "integer" } ],
120+
"additionalItems": { "type": "boolean" }
121+
},
122+
"tests": [
123+
{
124+
"description": "items defined in allOf are not examined",
125+
"data": [ 1, "hello" ],
126+
"valid": false
127+
}
128+
]
96129
}
97130
]

tests/draft2019-09/additionalProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
},
125125
"tests": [
126126
{
127-
"description": "properties defined in allOf are not allowed",
127+
"description": "properties defined in allOf are not examined",
128128
"data": {"foo": 1, "bar": true},
129129
"valid": false
130130
}

tests/draft3/additionalItems.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,21 @@
9393
"valid": true
9494
}
9595
]
96+
},
97+
{
98+
"description": "additionalItems should not look in applicators",
99+
"schema": {
100+
"extends": [
101+
{ "items": [ { "type": "integer" } ] }
102+
],
103+
"additionalItems": { "type": "boolean" }
104+
},
105+
"tests": [
106+
{
107+
"description": "items defined in extends are not examined",
108+
"data": [ 1, null ],
109+
"valid": true
110+
}
111+
]
96112
}
97113
]

tests/draft3/additionalProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
},
125125
"tests": [
126126
{
127-
"description": "properties defined in extends are not allowed",
127+
"description": "properties defined in extends are not examined",
128128
"data": {"foo": 1, "bar": true},
129129
"valid": false
130130
}

tests/draft4/additionalItems.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,38 @@
9393
"valid": true
9494
}
9595
]
96+
},
97+
{
98+
"description": "additionalItems should not look in applicators, valid case",
99+
"schema": {
100+
"allOf": [
101+
{ "items": [ { "type": "integer" } ] }
102+
],
103+
"additionalItems": { "type": "boolean" }
104+
},
105+
"tests": [
106+
{
107+
"description": "items defined in allOf are not examined",
108+
"data": [ 1, null ],
109+
"valid": true
110+
}
111+
]
112+
},
113+
{
114+
"description": "additionalItems should not look in applicators, invalid case",
115+
"schema": {
116+
"allOf": [
117+
{ "items": [ { "type": "integer" }, { "type": "string" } ] }
118+
],
119+
"items": [ {"type": "integer" } ],
120+
"additionalItems": { "type": "boolean" }
121+
},
122+
"tests": [
123+
{
124+
"description": "items defined in allOf are not examined",
125+
"data": [ 1, "hello" ],
126+
"valid": false
127+
}
128+
]
96129
}
97130
]

tests/draft4/additionalProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
},
125125
"tests": [
126126
{
127-
"description": "properties defined in allOf are not allowed",
127+
"description": "properties defined in allOf are not examined",
128128
"data": {"foo": 1, "bar": true},
129129
"valid": false
130130
}

tests/draft6/additionalItems.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,38 @@
9393
"valid": true
9494
}
9595
]
96+
},
97+
{
98+
"description": "additionalItems should not look in applicators, valid case",
99+
"schema": {
100+
"allOf": [
101+
{ "items": [ { "type": "integer" } ] }
102+
],
103+
"additionalItems": { "type": "boolean" }
104+
},
105+
"tests": [
106+
{
107+
"description": "items defined in allOf are not examined",
108+
"data": [ 1, null ],
109+
"valid": true
110+
}
111+
]
112+
},
113+
{
114+
"description": "additionalItems should not look in applicators, invalid case",
115+
"schema": {
116+
"allOf": [
117+
{ "items": [ { "type": "integer" }, { "type": "string" } ] }
118+
],
119+
"items": [ {"type": "integer" } ],
120+
"additionalItems": { "type": "boolean" }
121+
},
122+
"tests": [
123+
{
124+
"description": "items defined in allOf are not examined",
125+
"data": [ 1, "hello" ],
126+
"valid": false
127+
}
128+
]
96129
}
97130
]

tests/draft6/additionalProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
},
125125
"tests": [
126126
{
127-
"description": "properties defined in allOf are not allowed",
127+
"description": "properties defined in allOf are not examined",
128128
"data": {"foo": 1, "bar": true},
129129
"valid": false
130130
}

tests/draft7/additionalItems.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,5 +93,38 @@
9393
"valid": true
9494
}
9595
]
96+
},
97+
{
98+
"description": "additionalItems should not look in applicators, valid case",
99+
"schema": {
100+
"allOf": [
101+
{ "items": [ { "type": "integer" } ] }
102+
],
103+
"additionalItems": { "type": "boolean" }
104+
},
105+
"tests": [
106+
{
107+
"description": "items defined in allOf are not examined",
108+
"data": [ 1, null ],
109+
"valid": true
110+
}
111+
]
112+
},
113+
{
114+
"description": "additionalItems should not look in applicators, invalid case",
115+
"schema": {
116+
"allOf": [
117+
{ "items": [ { "type": "integer" }, { "type": "string" } ] }
118+
],
119+
"items": [ {"type": "integer" } ],
120+
"additionalItems": { "type": "boolean" }
121+
},
122+
"tests": [
123+
{
124+
"description": "items defined in allOf are not examined",
125+
"data": [ 1, "hello" ],
126+
"valid": false
127+
}
128+
]
96129
}
97130
]

tests/draft7/additionalProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
},
125125
"tests": [
126126
{
127-
"description": "properties defined in allOf are not allowed",
127+
"description": "properties defined in allOf are not examined",
128128
"data": {"foo": 1, "bar": true},
129129
"valid": false
130130
}

0 commit comments

Comments
 (0)