Skip to content

Commit 236b4b7

Browse files
committed
[301] Add tests for invalid "$anchor" syntax, remove wrapped "$ref"s
1 parent 240fbf6 commit 236b4b7

File tree

1 file changed

+51
-9
lines changed

1 file changed

+51
-9
lines changed

tests/draft2019-09/anchor.json

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
{
33
"description": "Location-independent identifier",
44
"schema": {
5-
"allOf": [{
6-
"$ref": "#foo"
7-
}],
5+
"$ref": "#foo",
86
"$defs": {
97
"A": {
108
"$anchor": "foo",
@@ -28,9 +26,7 @@
2826
{
2927
"description": "Location-independent identifier with absolute URI",
3028
"schema": {
31-
"allOf": [{
32-
"$ref": "http://localhost:1234/bar#foo"
33-
}],
29+
"$ref": "http://localhost:1234/bar#foo",
3430
"$defs": {
3531
"A": {
3632
"$id": "http://localhost:1234/bar",
@@ -56,9 +52,7 @@
5652
"description": "Location-independent identifier with base URI change in subschema",
5753
"schema": {
5854
"$id": "http://localhost:1234/root",
59-
"allOf": [{
60-
"$ref": "http://localhost:1234/nested.json#foo"
61-
}],
55+
"$ref": "http://localhost:1234/nested.json#foo",
6256
"$defs": {
6357
"A": {
6458
"$id": "nested.json",
@@ -83,5 +77,53 @@
8377
"valid": false
8478
}
8579
]
80+
},
81+
{
82+
"description": "Fragment syntax disallowed",
83+
"schema": {
84+
"$ref": "#foo",
85+
"$defs": {
86+
"A": {
87+
"$anchor": "#foo",
88+
"type": "integer"
89+
}
90+
}
91+
},
92+
"tests": [
93+
{
94+
"data": 1,
95+
"description": "match",
96+
"valid": false
97+
},
98+
{
99+
"data": "a",
100+
"description": "mismatch",
101+
"valid": false
102+
}
103+
]
104+
},
105+
{
106+
"description": "Invalid characters disallowed",
107+
"schema": {
108+
"$ref": "#/a/b",
109+
"$defs": {
110+
"A": {
111+
"$anchor": "/a/b",
112+
"type": "integer"
113+
}
114+
}
115+
},
116+
"tests": [
117+
{
118+
"data": 1,
119+
"description": "match",
120+
"valid": false
121+
},
122+
{
123+
"data": "a",
124+
"description": "mismatch",
125+
"valid": false
126+
}
127+
]
86128
}
87129
]

0 commit comments

Comments
 (0)