Skip to content

Commit c042465

Browse files
committed
[299] Add tests for invalid use of fragments in "$id"
1 parent 2576db4 commit c042465

File tree

1 file changed

+98
-2
lines changed

1 file changed

+98
-2
lines changed

tests/draft2019-09/ref.json

Lines changed: 98 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
"tests": [
274274
{
275275
"description": "valid tree",
276-
"data": {
276+
"data": {
277277
"meta": "root",
278278
"nodes": [
279279
{
@@ -302,7 +302,7 @@
302302
},
303303
{
304304
"description": "invalid tree",
305-
"data": {
305+
"data": {
306306
"meta": "root",
307307
"nodes": [
308308
{
@@ -358,6 +358,102 @@
358358
}
359359
]
360360
},
361+
{
362+
"description": "Invalid use of fragments in location-independent $id",
363+
"schema": {"$ref": "https://json-schema.org/draft/2019-09/schema"},
364+
"tests": [
365+
{
366+
"description": "Identifier name",
367+
"data": {
368+
"$ref": "#foo",
369+
"$defs": {
370+
"A": {
371+
"$id": "#foo",
372+
"type": "integer"
373+
}
374+
}
375+
},
376+
"valid": false
377+
},
378+
{
379+
"description": "Identifier path",
380+
"data": {
381+
"$ref": "#/a/b",
382+
"$defs": {
383+
"A": {
384+
"$id": "#/a/b",
385+
"type": "integer"
386+
}
387+
}
388+
},
389+
"valid": false
390+
},
391+
{
392+
"description": "Identifier name with absolute URI",
393+
"data": {
394+
"$ref": "http://localhost:1234/bar#foo",
395+
"$defs": {
396+
"A": {
397+
"$id": "http://localhost:1234/bar#foo",
398+
"type": "integer"
399+
}
400+
}
401+
},
402+
"valid": false
403+
},
404+
{
405+
"description": "Identifier path with absolute URI",
406+
"data": {
407+
"$ref": "http://localhost:1234/bar#/a/b",
408+
"$defs": {
409+
"A": {
410+
"$id": "http://localhost:1234/bar#/a/b",
411+
"type": "integer"
412+
}
413+
}
414+
},
415+
"valid": false
416+
},
417+
{
418+
"description": "Identifier name with base URI change in subschema",
419+
"data": {
420+
"$id": "http://localhost:1234/root",
421+
"$ref": "http://localhost:1234/nested.json#foo",
422+
"$defs": {
423+
"A": {
424+
"$id": "nested.json",
425+
"$defs": {
426+
"B": {
427+
"$id": "#foo",
428+
"type": "integer"
429+
}
430+
}
431+
}
432+
}
433+
},
434+
"valid": false
435+
},
436+
{
437+
"description": "Identifier path with base URI change in subschema",
438+
"data": {
439+
"$id": "http://localhost:1234/root",
440+
"$ref": "http://localhost:1234/nested.json#/a/b",
441+
"$defs": {
442+
"A": {
443+
"$id": "nested.json",
444+
"$defs": {
445+
"B": {
446+
"$id": "#/a/b",
447+
"type": "integer"
448+
}
449+
}
450+
}
451+
}
452+
},
453+
"valid": false
454+
}
455+
]
456+
},
361457
{
362458
"description": "ref creates new scope when adjacent to keywords",
363459
"schema": {

0 commit comments

Comments
 (0)