Skip to content

Commit

Permalink
Merge pull request #128 from iainbeeston/foundations-of-json-schema-p…
Browse files Browse the repository at this point in the history
…aper

Added test cases from Foundations of JSON Schema research paper
  • Loading branch information
gregsdennis authored Apr 21, 2023
2 parents cf76770 + 07fd389 commit 8025fc0
Show file tree
Hide file tree
Showing 12 changed files with 258 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/draft-next/dependentSchemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,43 @@
"valid": false
}
]
},
{
"description": "dependent subschema incompatible with root",
"schema": {
"properties": {
"foo": {}
},
"dependentSchemas": {
"foo": {
"properties": {
"bar": {}
},
"additionalProperties": false
}
}
},
"tests": [
{
"description": "matches root",
"data": {"foo": 1},
"valid": false
},
{
"description": "matches dependency",
"data": {"bar": 1},
"valid": true
},
{
"description": "matches both",
"data": {"foo": 1, "bar": 2},
"valid": false
},
{
"description": "no dependency",
"data": {"baz": 1},
"valid": true
}
]
}
]
5 changes: 5 additions & 0 deletions tests/draft-next/uniqueItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"data": [{"foo": "bar"}, {"foo": "bar"}],
"valid": false
},
{
"description": "property order of array of objects is ignored",
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
"valid": false
},
{
"description": "unique array of nested objects is valid",
"data": [
Expand Down
38 changes: 38 additions & 0 deletions tests/draft2019-09/dependentSchemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,43 @@
"valid": false
}
]
},
{
"description": "dependent subschema incompatible with root",
"schema": {
"properties": {
"foo": {}
},
"dependentSchemas": {
"foo": {
"properties": {
"bar": {}
},
"additionalProperties": false
}
}
},
"tests": [
{
"description": "matches root",
"data": {"foo": 1},
"valid": false
},
{
"description": "matches dependency",
"data": {"bar": 1},
"valid": true
},
{
"description": "matches both",
"data": {"foo": 1, "bar": 2},
"valid": false
},
{
"description": "no dependency",
"data": {"baz": 1},
"valid": true
}
]
}
]
5 changes: 5 additions & 0 deletions tests/draft2019-09/uniqueItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"data": [{"foo": "bar"}, {"foo": "bar"}],
"valid": false
},
{
"description": "property order of array of objects is ignored",
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
"valid": false
},
{
"description": "unique array of nested objects is valid",
"data": [
Expand Down
38 changes: 38 additions & 0 deletions tests/draft2020-12/dependentSchemas.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,43 @@
"valid": false
}
]
},
{
"description": "dependent subschema incompatible with root",
"schema": {
"properties": {
"foo": {}
},
"dependentSchemas": {
"foo": {
"properties": {
"bar": {}
},
"additionalProperties": false
}
}
},
"tests": [
{
"description": "matches root",
"data": {"foo": 1},
"valid": false
},
{
"description": "matches dependency",
"data": {"bar": 1},
"valid": true
},
{
"description": "matches both",
"data": {"foo": 1, "bar": 2},
"valid": false
},
{
"description": "no dependency",
"data": {"baz": 1},
"valid": true
}
]
}
]
5 changes: 5 additions & 0 deletions tests/draft2020-12/uniqueItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@
"data": [{"foo": "bar"}, {"foo": "bar"}],
"valid": false
},
{
"description": "property order of array of objects is ignored",
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
"valid": false
},
{
"description": "unique array of nested objects is valid",
"data": [
Expand Down
38 changes: 38 additions & 0 deletions tests/draft4/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,43 @@
"valid": false
}
]
},
{
"description": "dependent subschema incompatible with root",
"schema": {
"properties": {
"foo": {}
},
"dependencies": {
"foo": {
"properties": {
"bar": {}
},
"additionalProperties": false
}
}
},
"tests": [
{
"description": "matches root",
"data": {"foo": 1},
"valid": false
},
{
"description": "matches dependency",
"data": {"bar": 1},
"valid": true
},
{
"description": "matches both",
"data": {"foo": 1, "bar": 2},
"valid": false
},
{
"description": "no dependency",
"data": {"baz": 1},
"valid": true
}
]
}
]
5 changes: 5 additions & 0 deletions tests/draft4/uniqueItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
"data": [{"foo": "bar"}, {"foo": "bar"}],
"valid": false
},
{
"description": "property order of array of objects is ignored",
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
"valid": false
},
{
"description": "unique array of nested objects is valid",
"data": [
Expand Down
38 changes: 38 additions & 0 deletions tests/draft6/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,43 @@
"valid": false
}
]
},
{
"description": "dependent subschema incompatible with root",
"schema": {
"properties": {
"foo": {}
},
"dependencies": {
"foo": {
"properties": {
"bar": {}
},
"additionalProperties": false
}
}
},
"tests": [
{
"description": "matches root",
"data": {"foo": 1},
"valid": false
},
{
"description": "matches dependency",
"data": {"bar": 1},
"valid": true
},
{
"description": "matches both",
"data": {"foo": 1, "bar": 2},
"valid": false
},
{
"description": "no dependency",
"data": {"baz": 1},
"valid": true
}
]
}
]
5 changes: 5 additions & 0 deletions tests/draft6/uniqueItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
"data": [{"foo": "bar"}, {"foo": "bar"}],
"valid": false
},
{
"description": "property order of array of objects is ignored",
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
"valid": false
},
{
"description": "unique array of nested objects is valid",
"data": [
Expand Down
38 changes: 38 additions & 0 deletions tests/draft7/dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,5 +244,43 @@
"valid": false
}
]
},
{
"description": "dependent subschema incompatible with root",
"schema": {
"properties": {
"foo": {}
},
"dependencies": {
"foo": {
"properties": {
"bar": {}
},
"additionalProperties": false
}
}
},
"tests": [
{
"description": "matches root",
"data": {"foo": 1},
"valid": false
},
{
"description": "matches dependency",
"data": {"bar": 1},
"valid": true
},
{
"description": "matches both",
"data": {"foo": 1, "bar": 2},
"valid": false
},
{
"description": "no dependency",
"data": {"baz": 1},
"valid": true
}
]
}
]
5 changes: 5 additions & 0 deletions tests/draft7/uniqueItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
"data": [{"foo": "bar"}, {"foo": "bar"}],
"valid": false
},
{
"description": "property order of array of objects is ignored",
"data": [{"foo": "bar", "bar": "foo"}, {"bar": "foo", "foo": "bar"}],
"valid": false
},
{
"description": "unique array of nested objects is valid",
"data": [
Expand Down

0 comments on commit 8025fc0

Please sign in to comment.