Skip to content

Commit f300dd1

Browse files
santhosh-tekurijdesrosiers
authored andcommitted
Add test "same $anchor with different base uri"
1 parent d128f9d commit f300dd1

File tree

3 files changed

+105
-0
lines changed

3 files changed

+105
-0
lines changed

tests/draft-future/anchor.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,40 @@
134134
"valid": false
135135
}
136136
]
137+
},
138+
{
139+
"description": "same $anchor with different base uri",
140+
"schema": {
141+
"$id": "http://localhost:1234/foobar",
142+
"$defs": {
143+
"A": {
144+
"$id": "child1",
145+
"allOf": [
146+
{
147+
"$id": "child2",
148+
"$anchor": "my_anchor",
149+
"type": "number"
150+
},
151+
{
152+
"$anchor": "my_anchor",
153+
"type": "string"
154+
}
155+
]
156+
}
157+
},
158+
"$ref": "child1#my_anchor"
159+
},
160+
"tests": [
161+
{
162+
"description": "$ref should resolve to /$defs/A/allOf/1",
163+
"data": "a",
164+
"valid": true
165+
},
166+
{
167+
"description": "$ref should not resolve to /$defs/A/allOf/0",
168+
"data": 1,
169+
"valid": false
170+
}
171+
]
137172
}
138173
]

tests/draft2019-09/anchor.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,40 @@
134134
"valid": false
135135
}
136136
]
137+
},
138+
{
139+
"description": "same $anchor with different base uri",
140+
"schema": {
141+
"$id": "http://localhost:1234/foobar",
142+
"$defs": {
143+
"A": {
144+
"$id": "child1",
145+
"allOf": [
146+
{
147+
"$id": "child2",
148+
"$anchor": "my_anchor",
149+
"type": "number"
150+
},
151+
{
152+
"$anchor": "my_anchor",
153+
"type": "string"
154+
}
155+
]
156+
}
157+
},
158+
"$ref": "child1#my_anchor"
159+
},
160+
"tests": [
161+
{
162+
"description": "$ref should resolve to /$defs/A/allOf/1",
163+
"data": "a",
164+
"valid": true
165+
},
166+
{
167+
"description": "$ref should not resolve to /$defs/A/allOf/0",
168+
"data": 1,
169+
"valid": false
170+
}
171+
]
137172
}
138173
]

tests/draft2020-12/anchor.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,5 +134,40 @@
134134
"valid": false
135135
}
136136
]
137+
},
138+
{
139+
"description": "same $anchor with different base uri",
140+
"schema": {
141+
"$id": "http://localhost:1234/foobar",
142+
"$defs": {
143+
"A": {
144+
"$id": "child1",
145+
"allOf": [
146+
{
147+
"$id": "child2",
148+
"$anchor": "my_anchor",
149+
"type": "number"
150+
},
151+
{
152+
"$anchor": "my_anchor",
153+
"type": "string"
154+
}
155+
]
156+
}
157+
},
158+
"$ref": "child1#my_anchor"
159+
},
160+
"tests": [
161+
{
162+
"description": "$ref should resolve to /$defs/A/allOf/1",
163+
"data": "a",
164+
"valid": true
165+
},
166+
{
167+
"description": "$ref should not resolve to /$defs/A/allOf/0",
168+
"data": 1,
169+
"valid": false
170+
}
171+
]
137172
}
138173
]

0 commit comments

Comments
 (0)