Skip to content

Commit

Permalink
Squashed 'json/' changes from 95fe6ca2..d38ddd54
Browse files Browse the repository at this point in the history
d38ddd54 Merge pull request #696 from jdesrosiers/unevaluated-dynamicref
5d0c05fa Fix copy/paste error
49222046 Add unevaluted with dynamic ref tests to draft-next
8ba1c90d Update unevaluted with dynamic ref to be more likely to catch errors
2834c630 Add tests for unevaluated with dynamic reference

git-subtree-dir: json
git-subtree-split: d38ddd543ebc81e5c23ab03d6598c06563c38a17
  • Loading branch information
Julian committed Nov 16, 2023
1 parent 2ed7ad6 commit 13bc188
Show file tree
Hide file tree
Showing 6 changed files with 297 additions and 0 deletions.
42 changes: 42 additions & 0 deletions json/tests/draft-next/unevaluatedItems.json
Expand Up @@ -461,6 +461,48 @@
}
]
},
{
"description": "unevaluatedItems with $dynamicRef",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"$id": "https://example.com/derived",

"$ref": "/baseSchema",

"$defs": {
"derived": {
"$dynamicAnchor": "addons",
"prefixItems": [
true,
{ "type": "string" }
]
},
"baseSchema": {
"$id": "/baseSchema",

"$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
"unevaluatedItems": false,
"type": "array",
"prefixItems": [
{ "type": "string" }
],
"$dynamicRef": "#addons"
}
}
},
"tests": [
{
"description": "with no unevaluated items",
"data": ["foo", "bar"],
"valid": true
},
{
"description": "with unevaluated items",
"data": ["foo", "bar", "baz"],
"valid": false
}
]
},
{
"description": "unevaluatedItems can't see inside cousins",
"schema": {
Expand Down
48 changes: 48 additions & 0 deletions json/tests/draft-next/unevaluatedProperties.json
Expand Up @@ -715,6 +715,54 @@
}
]
},
{
"description": "unevaluatedProperties with $dynamicRef",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"$id": "https://example.com/derived",

"$ref": "/baseSchema",

"$defs": {
"derived": {
"$dynamicAnchor": "addons",
"properties": {
"bar": { "type": "string" }
}
},
"baseSchema": {
"$id": "/baseSchema",

"$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
"unevaluatedProperties": false,
"type": "object",
"properties": {
"foo": { "type": "string" }
},
"$dynamicRef": "#addons"
}
}
},
"tests": [
{
"description": "with no unevaluated properties",
"data": {
"foo": "foo",
"bar": "bar"
},
"valid": true
},
{
"description": "with unevaluated properties",
"data": {
"foo": "foo",
"bar": "bar",
"baz": "baz"
},
"valid": false
}
]
},
{
"description": "unevaluatedProperties can't see inside cousins",
"schema": {
Expand Down
45 changes: 45 additions & 0 deletions json/tests/draft2019-09/unevaluatedItems.json
Expand Up @@ -480,6 +480,51 @@
}
]
},
{
"description": "unevaluatedItems with $recursiveRef",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://example.com/extended-tree",

"$recursiveAnchor": true,

"$ref": "/tree",
"items": [
true,
true,
{ "type": "string" }
],

"$defs": {
"tree": {
"$id": "/tree",
"$recursiveAnchor": true,

"type": "array",
"items": [
{ "type": "number" },
{
"$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
"unevaluatedItems": false,
"$recursiveRef": "#"
}
]
}
}
},
"tests": [
{
"description": "with no unevaluated items",
"data": [1, [2, [], "b"], "a"],
"valid": true
},
{
"description": "with unevaluated items",
"data": [1, [2, [], "b", "too many"], "a"],
"valid": false
}
]
},
{
"description": "unevaluatedItems can't see inside cousins",
"schema": {
Expand Down
58 changes: 58 additions & 0 deletions json/tests/draft2019-09/unevaluatedProperties.json
Expand Up @@ -715,6 +715,64 @@
}
]
},
{
"description": "unevaluatedProperties with $recursiveRef",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "https://example.com/extended-tree",

"$recursiveAnchor": true,

"$ref": "/tree",
"properties": {
"name": { "type": "string" }
},

"$defs": {
"tree": {
"$id": "/tree",
"$recursiveAnchor": true,

"type": "object",
"properties": {
"node": true,
"branches": {
"$comment": "unevaluatedProperties comes first so it's more likely to bugs errors with implementations that are sensitive to keyword ordering",
"unevaluatedProperties": false,
"$recursiveRef": "#"
}
},
"required": ["node"]
}
}
},
"tests": [
{
"description": "with no unevaluated properties",
"data": {
"name": "a",
"node": 1,
"branches": {
"name": "b",
"node": 2
}
},
"valid": true
},
{
"description": "with unevaluated properties",
"data": {
"name": "a",
"node": 1,
"branches": {
"foo": "b",
"node": 2
}
},
"valid": false
}
]
},
{
"description": "unevaluatedProperties can't see inside cousins",
"schema": {
Expand Down
49 changes: 49 additions & 0 deletions json/tests/draft2020-12/unevaluatedItems.json
Expand Up @@ -461,6 +461,55 @@
}
]
},
{
"description": "unevaluatedItems with $dynamicRef",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/derived",

"$ref": "/baseSchema",

"$defs": {
"derived": {
"$dynamicAnchor": "addons",
"prefixItems": [
true,
{ "type": "string" }
]
},
"baseSchema": {
"$id": "/baseSchema",

"$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
"unevaluatedItems": false,
"type": "array",
"prefixItems": [
{ "type": "string" }
],
"$dynamicRef": "#addons",

"$defs": {
"defaultAddons": {
"$comment": "Needed to satisfy the bookending requirement",
"$dynamicAnchor": "addons"
}
}
}
}
},
"tests": [
{
"description": "with no unevaluated items",
"data": ["foo", "bar"],
"valid": true
},
{
"description": "with unevaluated items",
"data": ["foo", "bar", "baz"],
"valid": false
}
]
},
{
"description": "unevaluatedItems can't see inside cousins",
"schema": {
Expand Down
55 changes: 55 additions & 0 deletions json/tests/draft2020-12/unevaluatedProperties.json
Expand Up @@ -715,6 +715,61 @@
}
]
},
{
"description": "unevaluatedProperties with $dynamicRef",
"schema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://example.com/derived",

"$ref": "/baseSchema",

"$defs": {
"derived": {
"$dynamicAnchor": "addons",
"properties": {
"bar": { "type": "string" }
}
},
"baseSchema": {
"$id": "/baseSchema",

"$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
"unevaluatedProperties": false,
"type": "object",
"properties": {
"foo": { "type": "string" }
},
"$dynamicRef": "#addons",

"$defs": {
"defaultAddons": {
"$comment": "Needed to satisfy the bookending requirement",
"$dynamicAnchor": "addons"
}
}
}
}
},
"tests": [
{
"description": "with no unevaluated properties",
"data": {
"foo": "foo",
"bar": "bar"
},
"valid": true
},
{
"description": "with unevaluated properties",
"data": {
"foo": "foo",
"bar": "bar",
"baz": "baz"
},
"valid": false
}
]
},
{
"description": "unevaluatedProperties can't see inside cousins",
"schema": {
Expand Down

0 comments on commit 13bc188

Please sign in to comment.