Skip to content

Commit 037b443

Browse files
committed
Squashed 'json/' changes from 96742ba3..3627cc11
3627cc11 Fix draft3 as well, which didn't have allOf. eb1618b5 Fix misspelled reference in infinite-loop-detection tests d7821b62 remove duplicate files added by mistake in PR#446 a27c949b Merge pull request #446 from json-schema-org/ether/infinite-loop-detection 371fcaba Add a test to demonstrate the invalidity of a naive infinite loop detection algorithm 45436c6c Add a test to demonstrate the invalidity of a naive infinite loop detection algorithm 14cfcde1 Merge pull request #445 from json-schema-org/ether/naive-ref-replacement 128146da test that literal $refs are not evaluated as keywords 71ba357b Merge pull request #442 from jimblackler/master a6f759aa Update README.md 0f35b324 Merge pull request #441 from plxel/patch-1 d36b8b97 Update README.md d657d2b8 Update index.js 6a925b8d change folder to baseUriChange git-subtree-dir: json git-subtree-split: 3627cc1178c0ff03d2e3eacf4162d32091d21763
1 parent 918803a commit 037b443

12 files changed

+295
-1
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ This suite is being used by:
122122
* [networknt/json-schema-validator](https://github.com/networknt/json-schema-validator)
123123
* [Justify](https://github.com/leadpony/justify)
124124
* [Snow](https://github.com/ssilverman/snowy-json)
125+
* [jsonschemafriend](https://github.com/jimblackler/jsonschemafriend)
125126

126127
### JavaScript
127128

Diff for: index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ const jsonSchemaTest = require('json-schema-test');
66
const refs = {
77
'http://localhost:1234/integer.json': require('./remotes/integer.json'),
88
'http://localhost:1234/subSchemas.json': require('./remotes/subSchemas.json'),
9-
'http://localhost:1234/folder/folderInteger.json': require('./remotes/folder/folderInteger.json'),
9+
'http://localhost:1234/baseUriChange/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'),
10+
'http://localhost:1234/baseUriChangeFolder/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'),
11+
'http://localhost:1234/baseUriChangeFolderInSubschema/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'),
1012
'http://localhost:1234/name.json': require('./remotes/name.json'),
1113
'http://localhost:1234/name-defs.json': require('./remotes/name-defs.json')
1214
};

Diff for: tests/draft2019-09/infinite-loop-detection.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop",
4+
"schema": {
5+
"$defs": {
6+
"int": { "type": "integer" }
7+
},
8+
"allOf": [
9+
{
10+
"properties": {
11+
"foo": {
12+
"$ref": "#/$defs/int"
13+
}
14+
}
15+
},
16+
{
17+
"additionalProperties": {
18+
"$ref": "#/$defs/int"
19+
}
20+
}
21+
]
22+
},
23+
"tests": [
24+
{
25+
"description": "passing case",
26+
"data": { "foo": 1 },
27+
"valid": true
28+
},
29+
{
30+
"description": "failing case",
31+
"data": { "foo": "a string" },
32+
"valid": false
33+
}
34+
]
35+
}
36+
]

Diff for: tests/draft2019-09/ref.json

+23
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
]

Diff for: tests/draft3/infinite-loop-detection.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[
2+
{
3+
"description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop",
4+
"schema": {
5+
"definitions": {
6+
"int": { "type": "integer" }
7+
},
8+
"properties": {
9+
"foo": {
10+
"$ref": "#/definitions/int"
11+
}
12+
},
13+
"extends": {
14+
"additionalProperties": {
15+
"$ref": "#/definitions/int"
16+
}
17+
}
18+
},
19+
"tests": [
20+
{
21+
"description": "passing case",
22+
"data": { "foo": 1 },
23+
"valid": true
24+
},
25+
{
26+
"description": "failing case",
27+
"data": { "foo": "a string" },
28+
"valid": false
29+
}
30+
]
31+
}
32+
]

Diff for: tests/draft3/ref.json

+23
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
]

Diff for: tests/draft4/infinite-loop-detection.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop",
4+
"schema": {
5+
"definitions": {
6+
"int": { "type": "integer" }
7+
},
8+
"allOf": [
9+
{
10+
"properties": {
11+
"foo": {
12+
"$ref": "#/definitions/int"
13+
}
14+
}
15+
},
16+
{
17+
"additionalProperties": {
18+
"$ref": "#/definitions/int"
19+
}
20+
}
21+
]
22+
},
23+
"tests": [
24+
{
25+
"description": "passing case",
26+
"data": { "foo": 1 },
27+
"valid": true
28+
},
29+
{
30+
"description": "failing case",
31+
"data": { "foo": "a string" },
32+
"valid": false
33+
}
34+
]
35+
}
36+
]

Diff for: tests/draft4/ref.json

+23
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
]

Diff for: tests/draft6/infinite-loop-detection.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop",
4+
"schema": {
5+
"definitions": {
6+
"int": { "type": "integer" }
7+
},
8+
"allOf": [
9+
{
10+
"properties": {
11+
"foo": {
12+
"$ref": "#/definitions/int"
13+
}
14+
}
15+
},
16+
{
17+
"additionalProperties": {
18+
"$ref": "#/definitions/int"
19+
}
20+
}
21+
]
22+
},
23+
"tests": [
24+
{
25+
"description": "passing case",
26+
"data": { "foo": 1 },
27+
"valid": true
28+
},
29+
{
30+
"description": "failing case",
31+
"data": { "foo": "a string" },
32+
"valid": false
33+
}
34+
]
35+
}
36+
]

Diff for: tests/draft6/ref.json

+23
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
]

Diff for: tests/draft7/infinite-loop-detection.json

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
[
2+
{
3+
"description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop",
4+
"schema": {
5+
"definitions": {
6+
"int": { "type": "integer" }
7+
},
8+
"allOf": [
9+
{
10+
"properties": {
11+
"foo": {
12+
"$ref": "#/definitions/int"
13+
}
14+
}
15+
},
16+
{
17+
"additionalProperties": {
18+
"$ref": "#/definitions/int"
19+
}
20+
}
21+
]
22+
},
23+
"tests": [
24+
{
25+
"description": "passing case",
26+
"data": { "foo": 1 },
27+
"valid": true
28+
},
29+
{
30+
"description": "failing case",
31+
"data": { "foo": "a string" },
32+
"valid": false
33+
}
34+
]
35+
}
36+
]

Diff for: tests/draft7/ref.json

+23
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)