Skip to content

Commit

Permalink
Add tests for heterogeneous arrays with additionalItems
Browse files Browse the repository at this point in the history
We actually don't have any of these!

Ref: python-jsonschema/jsonschema#1157
  • Loading branch information
Julian committed Oct 20, 2023
1 parent a9a1e2e commit b8da838
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/draft-next/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,26 @@
}
]
},
{
"description": "items with heterogeneous array",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"prefixItems": [{}],
"items": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [ "foo", "bar", 37 ],
"valid": false
},
{
"description": "valid instance",
"data": [ null ],
"valid": true
}
]
},
{
"description": "items with null instance elements",
"schema": {
Expand Down
20 changes: 20 additions & 0 deletions tests/draft2019-09/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,26 @@
}
]
},
{
"description": "additionalItems with heterogeneous array",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": [{}],
"additionalItems": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [ "foo", "bar", 37 ],
"valid": false
},
{
"description": "valid instance",
"data": [ null ],
"valid": true
}
]
},
{
"description": "additionalItems with null instance elements",
"schema": {
Expand Down
20 changes: 20 additions & 0 deletions tests/draft2020-12/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,26 @@
}
]
},
{
"description": "items with heterogeneous array",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"prefixItems": [{}],
"items": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [ "foo", "bar", 37 ],
"valid": false
},
{
"description": "valid instance",
"data": [ null ],
"valid": true
}
]
},
{
"description": "items with null instance elements",
"schema": {
Expand Down
19 changes: 19 additions & 0 deletions tests/draft3/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,25 @@
}
]
},
{
"description": "additionalItems with heterogeneous array",
"schema": {
"items": [{}],
"additionalItems": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [ "foo", "bar", 37 ],
"valid": false
},
{
"description": "valid instance",
"data": [ null ],
"valid": true
}
]
},
{
"description": "additionalItems with null instance elements",
"schema": {
Expand Down
19 changes: 19 additions & 0 deletions tests/draft4/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,25 @@
}
]
},
{
"description": "additionalItems with heterogeneous array",
"schema": {
"items": [{}],
"additionalItems": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [ "foo", "bar", 37 ],
"valid": false
},
{
"description": "valid instance",
"data": [ null ],
"valid": true
}
]
},
{
"description": "additionalItems with null instance elements",
"schema": {
Expand Down
19 changes: 19 additions & 0 deletions tests/draft6/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@
}
]
},
{
"description": "additionalItems with heterogeneous array",
"schema": {
"items": [{}],
"additionalItems": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [ "foo", "bar", 37 ],
"valid": false
},
{
"description": "valid instance",
"data": [ null ],
"valid": true
}
]
},
{
"description": "additionalItems with null instance elements",
"schema": {
Expand Down
19 changes: 19 additions & 0 deletions tests/draft7/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,25 @@
}
]
},
{
"description": "additionalItems with heterogeneous array",
"schema": {
"items": [{}],
"additionalItems": false
},
"tests": [
{
"description": "heterogeneous invalid instance",
"data": [ "foo", "bar", 37 ],
"valid": false
},
{
"description": "valid instance",
"data": [ null ],
"valid": true
}
]
},
{
"description": "additionalItems with null instance elements",
"schema": {
Expand Down

0 comments on commit b8da838

Please sign in to comment.