Skip to content

Commit 14cfcde

Browse files
Merge pull request #445 from json-schema-org/ether/naive-ref-replacement
test that literal $refs are not evaluated as keywords
2 parents 71ba357 + 128146d commit 14cfcde

File tree

5 files changed

+115
-0
lines changed

5 files changed

+115
-0
lines changed

tests/draft2019-09/ref.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,5 +407,28 @@
407407
"valid": false
408408
}
409409
]
410+
},
411+
{
412+
"description": "naive replacement of $ref with its destination is not correct",
413+
"schema": {
414+
"$defs": {
415+
"a_string": { "type": "string" }
416+
},
417+
"enum": [
418+
{ "$ref": "#/$defs/a_string" }
419+
]
420+
},
421+
"tests": [
422+
{
423+
"description": "do not evaluate the $ref inside the enum",
424+
"data": "this is a string",
425+
"valid": false
426+
},
427+
{
428+
"description": "match the enum exactly",
429+
"data": { "$ref": "#/$defs/a_string" },
430+
"valid": true
431+
}
432+
]
410433
}
411434
]

tests/draft3/ref.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,28 @@
215215
"valid": false
216216
}
217217
]
218+
},
219+
{
220+
"description": "naive replacement of $ref with its destination is not correct",
221+
"schema": {
222+
"definitions": {
223+
"a_string": { "type": "string" }
224+
},
225+
"enum": [
226+
{ "$ref": "#/definitions/a_string" }
227+
]
228+
},
229+
"tests": [
230+
{
231+
"description": "do not evaluate the $ref inside the enum",
232+
"data": "this is a string",
233+
"valid": false
234+
},
235+
{
236+
"description": "match the enum exactly",
237+
"data": { "$ref": "#/definitions/a_string" },
238+
"valid": true
239+
}
240+
]
218241
}
219242
]

tests/draft4/ref.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,5 +434,28 @@
434434
"valid": false
435435
}
436436
]
437+
},
438+
{
439+
"description": "naive replacement of $ref with its destination is not correct",
440+
"schema": {
441+
"definitions": {
442+
"a_string": { "type": "string" }
443+
},
444+
"enum": [
445+
{ "$ref": "#/definitions/a_string" }
446+
]
447+
},
448+
"tests": [
449+
{
450+
"description": "do not evaluate the $ref inside the enum",
451+
"data": "this is a string",
452+
"valid": false
453+
},
454+
{
455+
"description": "match the enum exactly",
456+
"data": { "$ref": "#/definitions/a_string" },
457+
"valid": true
458+
}
459+
]
437460
}
438461
]

tests/draft6/ref.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,5 +466,28 @@
466466
"valid": false
467467
}
468468
]
469+
},
470+
{
471+
"description": "naive replacement of $ref with its destination is not correct",
472+
"schema": {
473+
"definitions": {
474+
"a_string": { "type": "string" }
475+
},
476+
"enum": [
477+
{ "$ref": "#/definitions/a_string" }
478+
]
479+
},
480+
"tests": [
481+
{
482+
"description": "do not evaluate the $ref inside the enum",
483+
"data": "this is a string",
484+
"valid": false
485+
},
486+
{
487+
"description": "match the enum exactly",
488+
"data": { "$ref": "#/definitions/a_string" },
489+
"valid": true
490+
}
491+
]
469492
}
470493
]

tests/draft7/ref.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,5 +466,28 @@
466466
"valid": false
467467
}
468468
]
469+
},
470+
{
471+
"description": "naive replacement of $ref with its destination is not correct",
472+
"schema": {
473+
"definitions": {
474+
"a_string": { "type": "string" }
475+
},
476+
"enum": [
477+
{ "$ref": "#/definitions/a_string" }
478+
]
479+
},
480+
"tests": [
481+
{
482+
"description": "do not evaluate the $ref inside the enum",
483+
"data": "this is a string",
484+
"valid": false
485+
},
486+
{
487+
"description": "match the enum exactly",
488+
"data": { "$ref": "#/definitions/a_string" },
489+
"valid": true
490+
}
491+
]
469492
}
470493
]

0 commit comments

Comments
 (0)