Skip to content

Commit 1899a5a

Browse files
authored
Merge pull request #308 from aznan2/master
issue #307 - test that oneOf handles missing optional property
2 parents 4a5010b + 37569b1 commit 1899a5a

File tree

4 files changed

+168
-0
lines changed

4 files changed

+168
-0
lines changed

tests/draft2019-09/oneOf.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,47 @@
202202
"valid": false
203203
}
204204
]
205+
},
206+
{
207+
"description": "oneOf with missing optional property",
208+
"schema": {
209+
"oneOf": [
210+
{
211+
"properties": {
212+
"bar": true,
213+
"baz": true
214+
},
215+
"required": ["bar"]
216+
},
217+
{
218+
"properties": {
219+
"foo": true
220+
},
221+
"required": ["foo"]
222+
}
223+
]
224+
},
225+
"tests": [
226+
{
227+
"description": "first oneOf valid",
228+
"data": {"bar": 8},
229+
"valid": true
230+
},
231+
{
232+
"description": "second oneOf valid",
233+
"data": {"foo": "foo"},
234+
"valid": true
235+
},
236+
{
237+
"description": "both oneOf valid",
238+
"data": {"foo": "foo", "bar": 8},
239+
"valid": false
240+
},
241+
{
242+
"description": "neither oneOf valid",
243+
"data": {"baz": "quux"},
244+
"valid": false
245+
}
246+
]
205247
}
206248
]

tests/draft4/oneOf.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,5 +158,47 @@
158158
"valid": false
159159
}
160160
]
161+
},
162+
{
163+
"description": "oneOf with missing optional property",
164+
"schema": {
165+
"oneOf": [
166+
{
167+
"properties": {
168+
"bar": {},
169+
"baz": {}
170+
},
171+
"required": ["bar"]
172+
},
173+
{
174+
"properties": {
175+
"foo": {}
176+
},
177+
"required": ["foo"]
178+
}
179+
]
180+
},
181+
"tests": [
182+
{
183+
"description": "first oneOf valid",
184+
"data": {"bar": 8},
185+
"valid": true
186+
},
187+
{
188+
"description": "second oneOf valid",
189+
"data": {"foo": "foo"},
190+
"valid": true
191+
},
192+
{
193+
"description": "both oneOf valid",
194+
"data": {"foo": "foo", "bar": 8},
195+
"valid": false
196+
},
197+
{
198+
"description": "neither oneOf valid",
199+
"data": {"baz": "quux"},
200+
"valid": false
201+
}
202+
]
161203
}
162204
]

tests/draft6/oneOf.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,47 @@
202202
"valid": false
203203
}
204204
]
205+
},
206+
{
207+
"description": "oneOf with missing optional property",
208+
"schema": {
209+
"oneOf": [
210+
{
211+
"properties": {
212+
"bar": true,
213+
"baz": true
214+
},
215+
"required": ["bar"]
216+
},
217+
{
218+
"properties": {
219+
"foo": true
220+
},
221+
"required": ["foo"]
222+
}
223+
]
224+
},
225+
"tests": [
226+
{
227+
"description": "first oneOf valid",
228+
"data": {"bar": 8},
229+
"valid": true
230+
},
231+
{
232+
"description": "second oneOf valid",
233+
"data": {"foo": "foo"},
234+
"valid": true
235+
},
236+
{
237+
"description": "both oneOf valid",
238+
"data": {"foo": "foo", "bar": 8},
239+
"valid": false
240+
},
241+
{
242+
"description": "neither oneOf valid",
243+
"data": {"baz": "quux"},
244+
"valid": false
245+
}
246+
]
205247
}
206248
]

tests/draft7/oneOf.json

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,5 +202,47 @@
202202
"valid": false
203203
}
204204
]
205+
},
206+
{
207+
"description": "oneOf with missing optional property",
208+
"schema": {
209+
"oneOf": [
210+
{
211+
"properties": {
212+
"bar": true,
213+
"baz": true
214+
},
215+
"required": ["bar"]
216+
},
217+
{
218+
"properties": {
219+
"foo": true
220+
},
221+
"required": ["foo"]
222+
}
223+
]
224+
},
225+
"tests": [
226+
{
227+
"description": "first oneOf valid",
228+
"data": {"bar": 8},
229+
"valid": true
230+
},
231+
{
232+
"description": "second oneOf valid",
233+
"data": {"foo": "foo"},
234+
"valid": true
235+
},
236+
{
237+
"description": "both oneOf valid",
238+
"data": {"foo": "foo", "bar": 8},
239+
"valid": false
240+
},
241+
{
242+
"description": "neither oneOf valid",
243+
"data": {"baz": "quux"},
244+
"valid": false
245+
}
246+
]
205247
}
206248
]

0 commit comments

Comments
 (0)