Skip to content

Commit

Permalink
Squashed 'json/' changes from b069ac352..5cc9214e8
Browse files Browse the repository at this point in the history
5cc9214e8 Merge pull request #681 from json-schema-org/gregsdennis/ref-to-ref-to-non-local-target
c946d3671 update previous test set to consistently use file extensions; add to draft-next
a0097d4d0 Merge pull request #679 from json-schema-org/gregsdennis/ref-to-ref-to-non-local-target
8b69249a1 added tests for checking the entire resource for anchors instead of just the local subschema
8cdfac41e Port new multiple dynamic paths test to draft-next
cd441d2e4 A whole new version of multiple dynamic paths
e93077e20 Simplify test for dynamic ref with multiple paths

git-subtree-dir: json
git-subtree-split: 5cc9214e82f1e0a5e9644960b6fe0166afb7b283
  • Loading branch information
Julian committed Aug 3, 2023
1 parent acf7a6b commit eb56578
Show file tree
Hide file tree
Showing 14 changed files with 342 additions and 56 deletions.
13 changes: 13 additions & 0 deletions remotes/draft-next/detached-dynamicref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$id": "http://localhost:1234/draft-next/detached-dynamicref.json",
"$schema": "https://json-schema.org/draft/next/schema",
"$defs": {
"foo": {
"$dynamicRef": "#detached"
},
"detached": {
"$dynamicAnchor": "detached",
"type": "integer"
}
}
}
13 changes: 13 additions & 0 deletions remotes/draft-next/detached-ref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$id": "http://localhost:1234/draft-next/detached-ref.json",
"$schema": "https://json-schema.org/draft/next/schema",
"$defs": {
"foo": {
"$ref": "#detached"
},
"detached": {
"$anchor": "detached",
"type": "integer"
}
}
}
13 changes: 13 additions & 0 deletions remotes/draft2019-09/detached-ref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$id": "http://localhost:1234/draft2019-09/detached-ref.json",
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$defs": {
"foo": {
"$ref": "#detached"
},
"detached": {
"$anchor": "detached",
"type": "integer"
}
}
}
13 changes: 13 additions & 0 deletions remotes/draft2020-12/detached-dynamicref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$id": "http://localhost:1234/draft2020-12/detached-dynamicref.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"foo": {
"$dynamicRef": "#detached"
},
"detached": {
"$dynamicAnchor": "detached",
"type": "integer"
}
}
}
13 changes: 13 additions & 0 deletions remotes/draft2020-12/detached-ref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$id": "http://localhost:1234/draft2020-12/detached-ref.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$defs": {
"foo": {
"$ref": "#detached"
},
"detached": {
"$anchor": "detached",
"type": "integer"
}
}
}
13 changes: 13 additions & 0 deletions remotes/draft6/detached-ref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$id": "http://localhost:1234/draft6/detached-ref.json",
"$schema": "http://json-schema.org/draft-06/schema#",
"definitions": {
"foo": {
"$ref": "#detached"
},
"detached": {
"$id": "#detached",
"type": "integer"
}
}
}
13 changes: 13 additions & 0 deletions remotes/draft7/detached-ref.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$id": "http://localhost:1234/draft7/detached-ref.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"foo": {
"$ref": "#detached"
},
"detached": {
"$id": "#detached",
"type": "integer"
}
}
}
104 changes: 76 additions & 28 deletions tests/draft-next/dynamicRef.json
Original file line number Diff line number Diff line change
Expand Up @@ -207,45 +207,75 @@
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"$id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main",
"$defs": {
"inner": {
"$id": "inner",
"$dynamicAnchor": "foo",
"title": "inner",
"additionalProperties": {
"$dynamicRef": "#foo"
}
"propertyDependencies": {
"kindOfList": {
"numbers": { "$ref": "numberList" },
"strings": { "$ref": "stringList" }
}
},
"if": {
"propertyNames": {
"pattern": "^[a-m]"
"$defs": {
"genericList": {
"$id": "genericList",
"properties": {
"list": {
"items": { "$dynamicRef": "#itemType" }
}
}
},
"numberList": {
"$id": "numberList",
"$defs": {
"itemType": {
"$dynamicAnchor": "itemType",
"type": "number"
}
},
"$ref": "genericList"
},
"stringList": {
"$id": "stringList",
"$defs": {
"itemType": {
"$dynamicAnchor": "itemType",
"type": "string"
}
},
"$ref": "genericList"
}
},
"then": {
"title": "any type of node",
"$id": "anyLeafNode",
"$dynamicAnchor": "foo",
"$ref": "inner"
},
"else": {
"title": "integer node",
"$id": "integerNode",
"$dynamicAnchor": "foo",
"type": [ "object", "integer" ],
"$ref": "inner"
}
},
"tests": [
{
"description": "recurse to anyLeafNode - floats are allowed",
"data": { "alpha": 1.1 },
"description": "number list with number values",
"data": {
"kindOfList": "numbers",
"list": [1.1]
},
"valid": true
},
{
"description": "recurse to integerNode - floats are not allowed",
"data": { "november": 1.1 },
"description": "number list with string values",
"data": {
"kindOfList": "numbers",
"list": ["foo"]
},
"valid": false
},
{
"description": "string list with number values",
"data": {
"kindOfList": "strings",
"list": [1.1]
},
"valid": false
},
{
"description": "string list with string values",
"data": {
"kindOfList": "strings",
"list": ["foo"]
},
"valid": true
}
]
},
Expand Down Expand Up @@ -564,5 +594,23 @@
"valid": false
}
]
},
{
"description": "$ref to $dynamicRef finds detached $dynamicAnchor",
"schema": {
"$ref": "http://localhost:1234/draft-next/detached-dynamicref.json#/$defs/foo"
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
18 changes: 18 additions & 0 deletions tests/draft-next/refRemote.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,23 @@
"valid": true
}
]
},
{
"description": "$ref to $ref finds detached $anchor",
"schema": {
"$ref": "http://localhost:1234/draft-next/detached-ref.json#/$defs/foo"
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
18 changes: 18 additions & 0 deletions tests/draft2019-09/refRemote.json
Original file line number Diff line number Diff line change
Expand Up @@ -310,5 +310,23 @@
"valid": true
}
]
},
{
"description": "$ref to $ref finds detached $anchor",
"schema": {
"$ref": "http://localhost:1234/draft2019-09/detached-ref.json#/$defs/foo"
},
"tests": [
{
"description": "number is valid",
"data": 1,
"valid": true
},
{
"description": "non-number is invalid",
"data": "a",
"valid": false
}
]
}
]
Loading

0 comments on commit eb56578

Please sign in to comment.