Skip to content

Commit d4d30f1

Browse files
committed
Add tests for location-independent identifiers
1 parent 2ca50c0 commit d4d30f1

File tree

3 files changed

+315
-0
lines changed

3 files changed

+315
-0
lines changed

tests/draft4/ref.json

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,5 +296,110 @@
296296
"valid": false
297297
}
298298
]
299+
},
300+
{
301+
"description": "Location-independent identifier",
302+
"schema": {
303+
"$ref": "#foo",
304+
"definitions": {
305+
"A": {
306+
"id": "#foo",
307+
"type": "integer"
308+
}
309+
}
310+
},
311+
"tests": [
312+
{
313+
"data": 1,
314+
"description": "match",
315+
"valid": true
316+
},
317+
{
318+
"data": "a",
319+
"description": "mismatch",
320+
"valid": false
321+
}
322+
]
323+
},
324+
{
325+
"description": "Canonical location-independent identifier",
326+
"schema": {
327+
"$ref": "http://localhost:1234/bar#foo",
328+
"definitions": {
329+
"A": {
330+
"id": "http://localhost:1234/bar#foo",
331+
"type": "integer"
332+
}
333+
}
334+
},
335+
"tests": [
336+
{
337+
"data": 1,
338+
"description": "match",
339+
"valid": true
340+
},
341+
{
342+
"data": "a",
343+
"description": "mismatch",
344+
"valid": false
345+
}
346+
]
347+
},
348+
{
349+
"description": "Location-independent identifier with base URI change in subschema",
350+
"schema": {
351+
"id": "http://localhost:1234/root",
352+
"$ref": "http://localhost:1234/nested.json#foo",
353+
"definitions": {
354+
"A": {
355+
"id": "nested.json",
356+
"definitions": {
357+
"B": {
358+
"id": "#foo",
359+
"type": "integer"
360+
}
361+
}
362+
}
363+
}
364+
},
365+
"tests": [
366+
{
367+
"data": 1,
368+
"description": "match",
369+
"valid": true
370+
},
371+
{
372+
"data": "a",
373+
"description": "mismatch",
374+
"valid": false
375+
}
376+
]
377+
},
378+
{
379+
"description": "Location-independent identifiers should take precedent over regular fragments",
380+
"schema": {
381+
"$ref": "#foo",
382+
"definitions": {
383+
"A": {
384+
"id": "#foo",
385+
"type": "integer"
386+
}
387+
},
388+
"foo": {
389+
"type": "string"
390+
}
391+
},
392+
"tests": [
393+
{
394+
"data": 1,
395+
"description": "match",
396+
"valid": true
397+
},
398+
{
399+
"data": "a",
400+
"description": "mismatch",
401+
"valid": false
402+
}
403+
]
299404
}
300405
]

tests/draft6/ref.json

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,5 +328,110 @@
328328
"valid": false
329329
}
330330
]
331+
},
332+
{
333+
"description": "Location-independent identifier",
334+
"schema": {
335+
"$ref": "#foo",
336+
"definitions": {
337+
"A": {
338+
"$id": "#foo",
339+
"type": "integer"
340+
}
341+
}
342+
},
343+
"tests": [
344+
{
345+
"data": 1,
346+
"description": "match",
347+
"valid": true
348+
},
349+
{
350+
"data": "a",
351+
"description": "mismatch",
352+
"valid": false
353+
}
354+
]
355+
},
356+
{
357+
"description": "Canonical location-independent identifier",
358+
"schema": {
359+
"$ref": "http://localhost:1234/bar#foo",
360+
"definitions": {
361+
"A": {
362+
"$id": "http://localhost:1234/bar#foo",
363+
"type": "integer"
364+
}
365+
}
366+
},
367+
"tests": [
368+
{
369+
"data": 1,
370+
"description": "match",
371+
"valid": true
372+
},
373+
{
374+
"data": "a",
375+
"description": "mismatch",
376+
"valid": false
377+
}
378+
]
379+
},
380+
{
381+
"description": "Location-independent identifier with base URI change in subschema",
382+
"schema": {
383+
"$id": "http://localhost:1234/root",
384+
"$ref": "http://localhost:1234/nested.json#foo",
385+
"definitions": {
386+
"A": {
387+
"$id": "nested.json",
388+
"definitions": {
389+
"B": {
390+
"$id": "#foo",
391+
"type": "integer"
392+
}
393+
}
394+
}
395+
}
396+
},
397+
"tests": [
398+
{
399+
"data": 1,
400+
"description": "match",
401+
"valid": true
402+
},
403+
{
404+
"data": "a",
405+
"description": "mismatch",
406+
"valid": false
407+
}
408+
]
409+
},
410+
{
411+
"description": "Location-independent identifiers should take precedent over regular fragments",
412+
"schema": {
413+
"$ref": "#foo",
414+
"definitions": {
415+
"A": {
416+
"$id": "#foo",
417+
"type": "integer"
418+
}
419+
},
420+
"foo": {
421+
"type": "string"
422+
}
423+
},
424+
"tests": [
425+
{
426+
"data": 1,
427+
"description": "match",
428+
"valid": true
429+
},
430+
{
431+
"data": "a",
432+
"description": "mismatch",
433+
"valid": false
434+
}
435+
]
331436
}
332437
]

tests/draft7/ref.json

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,5 +328,110 @@
328328
"valid": false
329329
}
330330
]
331+
},
332+
{
333+
"description": "Location-independent identifier",
334+
"schema": {
335+
"$ref": "#foo",
336+
"definitions": {
337+
"A": {
338+
"$id": "#foo",
339+
"type": "integer"
340+
}
341+
}
342+
},
343+
"tests": [
344+
{
345+
"data": 1,
346+
"description": "match",
347+
"valid": true
348+
},
349+
{
350+
"data": "a",
351+
"description": "mismatch",
352+
"valid": false
353+
}
354+
]
355+
},
356+
{
357+
"description": "Canonical location-independent identifier",
358+
"schema": {
359+
"$ref": "http://localhost:1234/bar#foo",
360+
"definitions": {
361+
"A": {
362+
"$id": "http://localhost:1234/bar#foo",
363+
"type": "integer"
364+
}
365+
}
366+
},
367+
"tests": [
368+
{
369+
"data": 1,
370+
"description": "match",
371+
"valid": true
372+
},
373+
{
374+
"data": "a",
375+
"description": "mismatch",
376+
"valid": false
377+
}
378+
]
379+
},
380+
{
381+
"description": "Location-independent identifier with base URI change in subschema",
382+
"schema": {
383+
"$id": "http://localhost:1234/root",
384+
"$ref": "http://localhost:1234/nested.json#foo",
385+
"definitions": {
386+
"A": {
387+
"$id": "nested.json",
388+
"definitions": {
389+
"B": {
390+
"$id": "#foo",
391+
"type": "integer"
392+
}
393+
}
394+
}
395+
}
396+
},
397+
"tests": [
398+
{
399+
"data": 1,
400+
"description": "match",
401+
"valid": true
402+
},
403+
{
404+
"data": "a",
405+
"description": "mismatch",
406+
"valid": false
407+
}
408+
]
409+
},
410+
{
411+
"description": "Location-independent identifiers should take precedent over regular fragments",
412+
"schema": {
413+
"$ref": "#foo",
414+
"definitions": {
415+
"A": {
416+
"$id": "#foo",
417+
"type": "integer"
418+
}
419+
},
420+
"foo": {
421+
"type": "string"
422+
}
423+
},
424+
"tests": [
425+
{
426+
"data": 1,
427+
"description": "match",
428+
"valid": true
429+
},
430+
{
431+
"data": "a",
432+
"description": "mismatch",
433+
"valid": false
434+
}
435+
]
331436
}
332437
]

0 commit comments

Comments
 (0)