Skip to content

Commit

Permalink
Merge commit '5e16d74500493ef164b595daec622c4ba199644e'
Browse files Browse the repository at this point in the history
* commit '5e16d74500493ef164b595daec622c4ba199644e':
  Squashed 'json/' changes from f57d3e0cc..19947eaa1
  • Loading branch information
Julian committed Mar 14, 2023
2 parents 1c286a1 + 5e16d74 commit f953e97
Show file tree
Hide file tree
Showing 38 changed files with 833 additions and 26 deletions.
2 changes: 2 additions & 0 deletions json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Drafts 04 and 03 are considered "frozen" in that less effort is put in to backpo
Additional coverage is always welcome, particularly for bugs encountered in real-world implementations.
If you see anything missing or incorrect, please feel free to [file an issue](https://github.com/json-schema-org/JSON-Schema-Test-Suite/issues) or [submit a PR](https://github.com/json-schema-org/JSON-Schema-Test-Suite).

@gregsdennis has also started a separate [test suite](https://github.com/gregsdennis/json-schema-vocab-test-suites) that is modelled after this suite to cover third-party vocabularies.

## Introduction to the Test Suite Structure

The tests in this suite are contained in the `tests` directory at the root of this repository.
Expand Down
13 changes: 13 additions & 0 deletions json/remotes/draft-next/metaschema-optional-vocabulary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json-schema.org/draft/next/schema",
"$id": "http://localhost:1234/draft-next/metaschema-optional-vocabulary.json",
"$vocabulary": {
"https://json-schema.org/draft/next/vocab/validation": true,
"https://json-schema.org/draft/next/vocab/core": true,
"http://localhost:1234/draft/next/vocab/custom": false
},
"allOf": [
{ "$ref": "https://json-schema.org/draft/next/meta/validation" },
{ "$ref": "https://json-schema.org/draft/next/meta/core" }
]
}
13 changes: 13 additions & 0 deletions json/remotes/draft2019-09/metaschema-optional-vocabulary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"$id": "http://localhost:1234/draft2019-09/metaschema-optional-vocabulary.json",
"$vocabulary": {
"https://json-schema.org/draft/2019-09/vocab/validation": true,
"https://json-schema.org/draft/2019-09/vocab/core": true,
"http://localhost:1234/draft/2019-09/vocab/custom": false
},
"allOf": [
{ "$ref": "https://json-schema.org/draft/2019-09/meta/validation" },
{ "$ref": "https://json-schema.org/draft/2019-09/meta/core" }
]
}
13 changes: 13 additions & 0 deletions json/remotes/draft2020-12/metaschema-optional-vocabulary.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json",
"$vocabulary": {
"https://json-schema.org/draft/2020-12/vocab/validation": true,
"https://json-schema.org/draft/2020-12/vocab/core": true,
"http://localhost:1234/draft/2020-12/vocab/custom": false
},
"allOf": [
{ "$ref": "https://json-schema.org/draft/2020-12/meta/validation" },
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" }
]
}
14 changes: 14 additions & 0 deletions json/tests/draft-next/multipleOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,19 @@
"valid": false
}
]
},
{
"description": "small multiple of large integer",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"type": "integer", "multipleOf": 1e-8
},
"tests": [
{
"description": "any integer is a multiple of 1e-8",
"data": 12391239123,
"valid": true
}
]
}
]
28 changes: 27 additions & 1 deletion json/tests/draft-next/not.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,31 @@
"valid": true
}
]
}
},
{
"description": "collect annotations inside a 'not', even if collection is disabled",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"not": {
"$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
"anyOf": [
true,
{ "properties": { "foo": true } }
],
"unevaluatedProperties": false
}
},
"tests": [
{
"description": "unevaluated property",
"data": { "bar": 1 },
"valid": true
},
{
"description": "annotations are still collected inside a 'not'",
"data": { "foo": 1 },
"valid": false
}
]
}
]
20 changes: 20 additions & 0 deletions json/tests/draft-next/optional/format/time.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@
"data": "08:30:06Z",
"valid": true
},
{
"description": "invalid time string with extra leading zeros",
"data": "008:030:006Z",
"valid": false
},
{
"description": "invalid time string with no leading zero for single digit",
"data": "8:3:6Z",
"valid": false
},
{
"description": "hour, minute, second must be two digits",
"data": "8:0030:6Z",
"valid": false
},
{
"description": "a valid time string with leap second, Zulu",
"data": "23:59:60Z",
Expand Down Expand Up @@ -131,6 +146,11 @@
"data": "08:30:06-08:00",
"valid": true
},
{
"description": "hour, minute in time-offset must be two digits",
"data": "08:30:06-8:000",
"valid": false
},
{
"description": "a valid time string with case-insensitive Z",
"data": "08:30:06z",
Expand Down
31 changes: 30 additions & 1 deletion json/tests/draft-next/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -949,5 +949,34 @@
"valid": true
}
]
}
},
{
"description": "ref with absolute-path-reference",
"schema": {
"$id": "http://example.com/ref/absref.json",
"$defs": {
"a": {
"$id": "http://example.com/ref/absref/foobar.json",
"type": "number"
},
"b": {
"$id": "http://example.com/absref/foobar.json",
"type": "string"
}
},
"$ref": "/absref/foobar.json"
},
"tests": [
{
"description": "a string is valid",
"data": "foo",
"valid": true
},
{
"description": "an integer is invalid",
"data": 12,
"valid": false
}
]
}
]
19 changes: 19 additions & 0 deletions json/tests/draft-next/refRemote.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@
}
]
},
{
"description": "anchor within remote ref",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"$ref": "http://localhost:1234/draft-next/locationIndependentIdentifier.json#foo"
},
"tests": [
{
"description": "remote anchor valid",
"data": 1,
"valid": true
},
{
"description": "remote anchor invalid",
"data": "a",
"valid": false
}
]
},
{
"description": "ref within remote ref",
"schema": {
Expand Down
23 changes: 22 additions & 1 deletion json/tests/draft-next/unevaluatedItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
]
},
{
"description": "unevaluatedItems with items",
"description": "unevaluatedItems with items and prefixItems",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"prefixItems": [
Expand All @@ -116,6 +116,27 @@
}
]
},
{
"description": "unevaluatedItems with items",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"items": {"type": "number"},
"unevaluatedItems": {"type": "string"}
},
"tests": [
{
"description": "valid under items",
"comment": "no elements are considered by unevaluatedItems",
"data": [5, 6, 7, 8],
"valid": true
},
{
"description": "invalid under items",
"data": ["foo", "bar", "baz"],
"valid": false
}
]
},
{
"description": "unevaluatedItems with nested tuple",
"schema": {
Expand Down
22 changes: 22 additions & 0 deletions json/tests/draft-next/unevaluatedProperties.json
Original file line number Diff line number Diff line change
Expand Up @@ -1516,5 +1516,27 @@
"valid": false
}
]
},
{
"description": "unevaluatedProperties not affected by propertyNames",
"schema": {
"$schema": "https://json-schema.org/draft/next/schema",
"propertyNames": {"maxLength": 1},
"unevaluatedProperties": {
"type": "number"
}
},
"tests": [
{
"description": "allows only number properties",
"data": {"a": 1},
"valid": true
},
{
"description": "string property is invalid",
"data": {"a": "b"},
"valid": false
}
]
}
]
21 changes: 20 additions & 1 deletion json/tests/draft-next/vocabulary.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,24 @@
"valid": true
}
]
}
},
{
"description": "ignore unrecognized optional vocabulary",
"schema": {
"$schema": "http://localhost:1234/draft-next/metaschema-optional-vocabulary.json",
"type": "number"
},
"tests": [
{
"description": "string value",
"data": "foobar",
"valid": false
},
{
"description": "number value",
"data": 20,
"valid": true
}
]
}
]
24 changes: 24 additions & 0 deletions json/tests/draft2019-09/additionalItems.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,30 @@
},
{
"description": "when items is schema, additionalItems does nothing",
"schema": {
"$schema":"https://json-schema.org/draft/2019-09/schema",
"items": {
"type": "integer"
},
"additionalItems": {
"type": "string"
}
},
"tests": [
{
"description": "valid with a array of type integers",
"data": [1,2,3],
"valid": true
},
{
"description": "invalid with a array of mixed types",
"data": [1,"2","3"],
"valid": false
}
]
},
{
"description": "when items is schema, boolean additionalItems does nothing",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"items": {},
Expand Down
14 changes: 14 additions & 0 deletions json/tests/draft2019-09/multipleOf.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,19 @@
"valid": false
}
]
},
{
"description": "small multiple of large integer",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"type": "integer", "multipleOf": 1e-8
},
"tests": [
{
"description": "any integer is a multiple of 1e-8",
"data": 12391239123,
"valid": true
}
]
}
]
28 changes: 27 additions & 1 deletion json/tests/draft2019-09/not.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,31 @@
"valid": true
}
]
}
},
{
"description": "collect annotations inside a 'not', even if collection is disabled",
"schema": {
"$schema": "https://json-schema.org/draft/2019-09/schema",
"not": {
"$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
"anyOf": [
true,
{ "properties": { "foo": true } }
],
"unevaluatedProperties": false
}
},
"tests": [
{
"description": "unevaluated property",
"data": { "bar": 1 },
"valid": true
},
{
"description": "annotations are still collected inside a 'not'",
"data": { "foo": 1 },
"valid": false
}
]
}
]
Loading

0 comments on commit f953e97

Please sign in to comment.