Skip to content

Commit f953e97

Browse files
committed
Merge commit '5e16d74500493ef164b595daec622c4ba199644e'
* commit '5e16d74500493ef164b595daec622c4ba199644e': Squashed 'json/' changes from f57d3e0cc..19947eaa1
2 parents 1c286a1 + 5e16d74 commit f953e97

38 files changed

+833
-26
lines changed

json/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Drafts 04 and 03 are considered "frozen" in that less effort is put in to backpo
2020
Additional coverage is always welcome, particularly for bugs encountered in real-world implementations.
2121
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).
2222

23+
@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.
24+
2325
## Introduction to the Test Suite Structure
2426

2527
The tests in this suite are contained in the `tests` directory at the root of this repository.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/next/schema",
3+
"$id": "http://localhost:1234/draft-next/metaschema-optional-vocabulary.json",
4+
"$vocabulary": {
5+
"https://json-schema.org/draft/next/vocab/validation": true,
6+
"https://json-schema.org/draft/next/vocab/core": true,
7+
"http://localhost:1234/draft/next/vocab/custom": false
8+
},
9+
"allOf": [
10+
{ "$ref": "https://json-schema.org/draft/next/meta/validation" },
11+
{ "$ref": "https://json-schema.org/draft/next/meta/core" }
12+
]
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "http://localhost:1234/draft2019-09/metaschema-optional-vocabulary.json",
4+
"$vocabulary": {
5+
"https://json-schema.org/draft/2019-09/vocab/validation": true,
6+
"https://json-schema.org/draft/2019-09/vocab/core": true,
7+
"http://localhost:1234/draft/2019-09/vocab/custom": false
8+
},
9+
"allOf": [
10+
{ "$ref": "https://json-schema.org/draft/2019-09/meta/validation" },
11+
{ "$ref": "https://json-schema.org/draft/2019-09/meta/core" }
12+
]
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "http://localhost:1234/draft2020-12/metaschema-optional-vocabulary.json",
4+
"$vocabulary": {
5+
"https://json-schema.org/draft/2020-12/vocab/validation": true,
6+
"https://json-schema.org/draft/2020-12/vocab/core": true,
7+
"http://localhost:1234/draft/2020-12/vocab/custom": false
8+
},
9+
"allOf": [
10+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/validation" },
11+
{ "$ref": "https://json-schema.org/draft/2020-12/meta/core" }
12+
]
13+
}

json/tests/draft-next/multipleOf.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,19 @@
8080
"valid": false
8181
}
8282
]
83+
},
84+
{
85+
"description": "small multiple of large integer",
86+
"schema": {
87+
"$schema": "https://json-schema.org/draft/next/schema",
88+
"type": "integer", "multipleOf": 1e-8
89+
},
90+
"tests": [
91+
{
92+
"description": "any integer is a multiple of 1e-8",
93+
"data": 12391239123,
94+
"valid": true
95+
}
96+
]
8397
}
8498
]

json/tests/draft-next/not.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,31 @@
123123
"valid": true
124124
}
125125
]
126-
}
126+
},
127+
{
128+
"description": "collect annotations inside a 'not', even if collection is disabled",
129+
"schema": {
130+
"$schema": "https://json-schema.org/draft/next/schema",
131+
"not": {
132+
"$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
133+
"anyOf": [
134+
true,
135+
{ "properties": { "foo": true } }
136+
],
137+
"unevaluatedProperties": false
138+
}
139+
},
140+
"tests": [
141+
{
142+
"description": "unevaluated property",
143+
"data": { "bar": 1 },
144+
"valid": true
145+
},
146+
{
147+
"description": "annotations are still collected inside a 'not'",
148+
"data": { "foo": 1 },
149+
"valid": false
150+
}
151+
]
152+
}
127153
]

json/tests/draft-next/optional/format/time.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,21 @@
4141
"data": "08:30:06Z",
4242
"valid": true
4343
},
44+
{
45+
"description": "invalid time string with extra leading zeros",
46+
"data": "008:030:006Z",
47+
"valid": false
48+
},
49+
{
50+
"description": "invalid time string with no leading zero for single digit",
51+
"data": "8:3:6Z",
52+
"valid": false
53+
},
54+
{
55+
"description": "hour, minute, second must be two digits",
56+
"data": "8:0030:6Z",
57+
"valid": false
58+
},
4459
{
4560
"description": "a valid time string with leap second, Zulu",
4661
"data": "23:59:60Z",
@@ -131,6 +146,11 @@
131146
"data": "08:30:06-08:00",
132147
"valid": true
133148
},
149+
{
150+
"description": "hour, minute in time-offset must be two digits",
151+
"data": "08:30:06-8:000",
152+
"valid": false
153+
},
134154
{
135155
"description": "a valid time string with case-insensitive Z",
136156
"data": "08:30:06z",

json/tests/draft-next/ref.json

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,5 +949,34 @@
949949
"valid": true
950950
}
951951
]
952-
}
952+
},
953+
{
954+
"description": "ref with absolute-path-reference",
955+
"schema": {
956+
"$id": "http://example.com/ref/absref.json",
957+
"$defs": {
958+
"a": {
959+
"$id": "http://example.com/ref/absref/foobar.json",
960+
"type": "number"
961+
},
962+
"b": {
963+
"$id": "http://example.com/absref/foobar.json",
964+
"type": "string"
965+
}
966+
},
967+
"$ref": "/absref/foobar.json"
968+
},
969+
"tests": [
970+
{
971+
"description": "a string is valid",
972+
"data": "foo",
973+
"valid": true
974+
},
975+
{
976+
"description": "an integer is invalid",
977+
"data": 12,
978+
"valid": false
979+
}
980+
]
981+
}
953982
]

json/tests/draft-next/refRemote.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,25 @@
3737
}
3838
]
3939
},
40+
{
41+
"description": "anchor within remote ref",
42+
"schema": {
43+
"$schema": "https://json-schema.org/draft/next/schema",
44+
"$ref": "http://localhost:1234/draft-next/locationIndependentIdentifier.json#foo"
45+
},
46+
"tests": [
47+
{
48+
"description": "remote anchor valid",
49+
"data": 1,
50+
"valid": true
51+
},
52+
{
53+
"description": "remote anchor invalid",
54+
"data": "a",
55+
"valid": false
56+
}
57+
]
58+
},
4059
{
4160
"description": "ref within remote ref",
4261
"schema": {

json/tests/draft-next/unevaluatedItems.json

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
]
100100
},
101101
{
102-
"description": "unevaluatedItems with items",
102+
"description": "unevaluatedItems with items and prefixItems",
103103
"schema": {
104104
"$schema": "https://json-schema.org/draft/next/schema",
105105
"prefixItems": [
@@ -116,6 +116,27 @@
116116
}
117117
]
118118
},
119+
{
120+
"description": "unevaluatedItems with items",
121+
"schema": {
122+
"$schema": "https://json-schema.org/draft/next/schema",
123+
"items": {"type": "number"},
124+
"unevaluatedItems": {"type": "string"}
125+
},
126+
"tests": [
127+
{
128+
"description": "valid under items",
129+
"comment": "no elements are considered by unevaluatedItems",
130+
"data": [5, 6, 7, 8],
131+
"valid": true
132+
},
133+
{
134+
"description": "invalid under items",
135+
"data": ["foo", "bar", "baz"],
136+
"valid": false
137+
}
138+
]
139+
},
119140
{
120141
"description": "unevaluatedItems with nested tuple",
121142
"schema": {

json/tests/draft-next/unevaluatedProperties.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,5 +1516,27 @@
15161516
"valid": false
15171517
}
15181518
]
1519+
},
1520+
{
1521+
"description": "unevaluatedProperties not affected by propertyNames",
1522+
"schema": {
1523+
"$schema": "https://json-schema.org/draft/next/schema",
1524+
"propertyNames": {"maxLength": 1},
1525+
"unevaluatedProperties": {
1526+
"type": "number"
1527+
}
1528+
},
1529+
"tests": [
1530+
{
1531+
"description": "allows only number properties",
1532+
"data": {"a": 1},
1533+
"valid": true
1534+
},
1535+
{
1536+
"description": "string property is invalid",
1537+
"data": {"a": "b"},
1538+
"valid": false
1539+
}
1540+
]
15191541
}
15201542
]

json/tests/draft-next/vocabulary.json

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,24 @@
3434
"valid": true
3535
}
3636
]
37-
}
37+
},
38+
{
39+
"description": "ignore unrecognized optional vocabulary",
40+
"schema": {
41+
"$schema": "http://localhost:1234/draft-next/metaschema-optional-vocabulary.json",
42+
"type": "number"
43+
},
44+
"tests": [
45+
{
46+
"description": "string value",
47+
"data": "foobar",
48+
"valid": false
49+
},
50+
{
51+
"description": "number value",
52+
"data": 20,
53+
"valid": true
54+
}
55+
]
56+
}
3857
]

json/tests/draft2019-09/additionalItems.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,30 @@
2121
},
2222
{
2323
"description": "when items is schema, additionalItems does nothing",
24+
"schema": {
25+
"$schema":"https://json-schema.org/draft/2019-09/schema",
26+
"items": {
27+
"type": "integer"
28+
},
29+
"additionalItems": {
30+
"type": "string"
31+
}
32+
},
33+
"tests": [
34+
{
35+
"description": "valid with a array of type integers",
36+
"data": [1,2,3],
37+
"valid": true
38+
},
39+
{
40+
"description": "invalid with a array of mixed types",
41+
"data": [1,"2","3"],
42+
"valid": false
43+
}
44+
]
45+
},
46+
{
47+
"description": "when items is schema, boolean additionalItems does nothing",
2448
"schema": {
2549
"$schema": "https://json-schema.org/draft/2019-09/schema",
2650
"items": {},

json/tests/draft2019-09/multipleOf.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,19 @@
7979
"valid": false
8080
}
8181
]
82+
},
83+
{
84+
"description": "small multiple of large integer",
85+
"schema": {
86+
"$schema": "https://json-schema.org/draft/2019-09/schema",
87+
"type": "integer", "multipleOf": 1e-8
88+
},
89+
"tests": [
90+
{
91+
"description": "any integer is a multiple of 1e-8",
92+
"data": 12391239123,
93+
"valid": true
94+
}
95+
]
8296
}
8397
]

json/tests/draft2019-09/not.json

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,31 @@
123123
"valid": true
124124
}
125125
]
126-
}
126+
},
127+
{
128+
"description": "collect annotations inside a 'not', even if collection is disabled",
129+
"schema": {
130+
"$schema": "https://json-schema.org/draft/2019-09/schema",
131+
"not": {
132+
"$comment": "this subschema must still produce annotations internally, even though the 'not' will ultimately discard them",
133+
"anyOf": [
134+
true,
135+
{ "properties": { "foo": true } }
136+
],
137+
"unevaluatedProperties": false
138+
}
139+
},
140+
"tests": [
141+
{
142+
"description": "unevaluated property",
143+
"data": { "bar": 1 },
144+
"valid": true
145+
},
146+
{
147+
"description": "annotations are still collected inside a 'not'",
148+
"data": { "foo": 1 },
149+
"valid": false
150+
}
151+
]
152+
}
127153
]

0 commit comments

Comments
 (0)