diff options
author | Julian Berman <Julian@GrayVines.com> | 2020-11-17 08:50:10 -0500 |
---|---|---|
committer | Julian Berman <Julian@GrayVines.com> | 2020-11-17 08:50:10 -0500 |
commit | bb75153ad4efc86f1b5cb0b58d2eddba683769af (patch) | |
tree | 8b7abf72fcec1df633983e9a808f20583d03fda8 /json | |
parent | e4bafa6185c689b89ee1ddc9cf237776b794428b (diff) | |
parent | 037b4438fc54e52584cf8fb5e469cf3413751a1f (diff) | |
download | jsonschema-bb75153ad4efc86f1b5cb0b58d2eddba683769af.tar.gz |
Merge commit '037b4438fc54e52584cf8fb5e469cf3413751a1f' into main
* commit '037b4438fc54e52584cf8fb5e469cf3413751a1f':
Squashed 'json/' changes from 96742ba3..3627cc11
Diffstat (limited to 'json')
-rw-r--r-- | json/README.md | 1 | ||||
-rw-r--r-- | json/index.js | 4 | ||||
-rw-r--r-- | json/tests/draft2019-09/infinite-loop-detection.json | 36 | ||||
-rw-r--r-- | json/tests/draft2019-09/ref.json | 23 | ||||
-rw-r--r-- | json/tests/draft3/infinite-loop-detection.json | 32 | ||||
-rw-r--r-- | json/tests/draft3/ref.json | 23 | ||||
-rw-r--r-- | json/tests/draft4/infinite-loop-detection.json | 36 | ||||
-rw-r--r-- | json/tests/draft4/ref.json | 23 | ||||
-rw-r--r-- | json/tests/draft6/infinite-loop-detection.json | 36 | ||||
-rw-r--r-- | json/tests/draft6/ref.json | 23 | ||||
-rw-r--r-- | json/tests/draft7/infinite-loop-detection.json | 36 | ||||
-rw-r--r-- | json/tests/draft7/ref.json | 23 |
12 files changed, 295 insertions, 1 deletions
diff --git a/json/README.md b/json/README.md index 2b541ef..cfea40f 100644 --- a/json/README.md +++ b/json/README.md @@ -122,6 +122,7 @@ This suite is being used by: * [networknt/json-schema-validator](https://github.com/networknt/json-schema-validator) * [Justify](https://github.com/leadpony/justify) * [Snow](https://github.com/ssilverman/snowy-json) +* [jsonschemafriend](https://github.com/jimblackler/jsonschemafriend) ### JavaScript diff --git a/json/index.js b/json/index.js index 16dc3a5..7d01093 100644 --- a/json/index.js +++ b/json/index.js @@ -6,7 +6,9 @@ const jsonSchemaTest = require('json-schema-test'); const refs = { 'http://localhost:1234/integer.json': require('./remotes/integer.json'), 'http://localhost:1234/subSchemas.json': require('./remotes/subSchemas.json'), - 'http://localhost:1234/folder/folderInteger.json': require('./remotes/folder/folderInteger.json'), + 'http://localhost:1234/baseUriChange/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'), + 'http://localhost:1234/baseUriChangeFolder/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'), + 'http://localhost:1234/baseUriChangeFolderInSubschema/folderInteger.json': require('./remotes/baseUriChange/folderInteger.json'), 'http://localhost:1234/name.json': require('./remotes/name.json'), 'http://localhost:1234/name-defs.json': require('./remotes/name-defs.json') }; diff --git a/json/tests/draft2019-09/infinite-loop-detection.json b/json/tests/draft2019-09/infinite-loop-detection.json new file mode 100644 index 0000000..9c3c362 --- /dev/null +++ b/json/tests/draft2019-09/infinite-loop-detection.json @@ -0,0 +1,36 @@ +[ + { + "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", + "schema": { + "$defs": { + "int": { "type": "integer" } + }, + "allOf": [ + { + "properties": { + "foo": { + "$ref": "#/$defs/int" + } + } + }, + { + "additionalProperties": { + "$ref": "#/$defs/int" + } + } + ] + }, + "tests": [ + { + "description": "passing case", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "failing case", + "data": { "foo": "a string" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft2019-09/ref.json b/json/tests/draft2019-09/ref.json index 97f7054..2da81e3 100644 --- a/json/tests/draft2019-09/ref.json +++ b/json/tests/draft2019-09/ref.json @@ -407,5 +407,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "$defs": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/$defs/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/$defs/a_string" }, + "valid": true + } + ] } ] diff --git a/json/tests/draft3/infinite-loop-detection.json b/json/tests/draft3/infinite-loop-detection.json new file mode 100644 index 0000000..090f49a --- /dev/null +++ b/json/tests/draft3/infinite-loop-detection.json @@ -0,0 +1,32 @@ +[ + { + "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", + "schema": { + "definitions": { + "int": { "type": "integer" } + }, + "properties": { + "foo": { + "$ref": "#/definitions/int" + } + }, + "extends": { + "additionalProperties": { + "$ref": "#/definitions/int" + } + } + }, + "tests": [ + { + "description": "passing case", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "failing case", + "data": { "foo": "a string" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft3/ref.json b/json/tests/draft3/ref.json index 77b2947..ebdb236 100644 --- a/json/tests/draft3/ref.json +++ b/json/tests/draft3/ref.json @@ -215,5 +215,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] } ] diff --git a/json/tests/draft4/infinite-loop-detection.json b/json/tests/draft4/infinite-loop-detection.json new file mode 100644 index 0000000..f98c74f --- /dev/null +++ b/json/tests/draft4/infinite-loop-detection.json @@ -0,0 +1,36 @@ +[ + { + "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", + "schema": { + "definitions": { + "int": { "type": "integer" } + }, + "allOf": [ + { + "properties": { + "foo": { + "$ref": "#/definitions/int" + } + } + }, + { + "additionalProperties": { + "$ref": "#/definitions/int" + } + } + ] + }, + "tests": [ + { + "description": "passing case", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "failing case", + "data": { "foo": "a string" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft4/ref.json b/json/tests/draft4/ref.json index f88e963..820839d 100644 --- a/json/tests/draft4/ref.json +++ b/json/tests/draft4/ref.json @@ -434,5 +434,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] } ] diff --git a/json/tests/draft6/infinite-loop-detection.json b/json/tests/draft6/infinite-loop-detection.json new file mode 100644 index 0000000..f98c74f --- /dev/null +++ b/json/tests/draft6/infinite-loop-detection.json @@ -0,0 +1,36 @@ +[ + { + "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", + "schema": { + "definitions": { + "int": { "type": "integer" } + }, + "allOf": [ + { + "properties": { + "foo": { + "$ref": "#/definitions/int" + } + } + }, + { + "additionalProperties": { + "$ref": "#/definitions/int" + } + } + ] + }, + "tests": [ + { + "description": "passing case", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "failing case", + "data": { "foo": "a string" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft6/ref.json b/json/tests/draft6/ref.json index 0138382..3bb0efc 100644 --- a/json/tests/draft6/ref.json +++ b/json/tests/draft6/ref.json @@ -466,5 +466,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] } ] diff --git a/json/tests/draft7/infinite-loop-detection.json b/json/tests/draft7/infinite-loop-detection.json new file mode 100644 index 0000000..f98c74f --- /dev/null +++ b/json/tests/draft7/infinite-loop-detection.json @@ -0,0 +1,36 @@ +[ + { + "description": "evaluating the same schema location against the same data location twice is not a sign of an infinite loop", + "schema": { + "definitions": { + "int": { "type": "integer" } + }, + "allOf": [ + { + "properties": { + "foo": { + "$ref": "#/definitions/int" + } + } + }, + { + "additionalProperties": { + "$ref": "#/definitions/int" + } + } + ] + }, + "tests": [ + { + "description": "passing case", + "data": { "foo": 1 }, + "valid": true + }, + { + "description": "failing case", + "data": { "foo": "a string" }, + "valid": false + } + ] + } +] diff --git a/json/tests/draft7/ref.json b/json/tests/draft7/ref.json index 01ba9fa..97ddf07 100644 --- a/json/tests/draft7/ref.json +++ b/json/tests/draft7/ref.json @@ -466,5 +466,28 @@ "valid": false } ] + }, + { + "description": "naive replacement of $ref with its destination is not correct", + "schema": { + "definitions": { + "a_string": { "type": "string" } + }, + "enum": [ + { "$ref": "#/definitions/a_string" } + ] + }, + "tests": [ + { + "description": "do not evaluate the $ref inside the enum", + "data": "this is a string", + "valid": false + }, + { + "description": "match the enum exactly", + "data": { "$ref": "#/definitions/a_string" }, + "valid": true + } + ] } ] |