Skip to content

Commit c19f0b4

Browse files
committed
Squashed 'json/' changes from 15ec577f..09fd353f
09fd353f Merge pull request #481 from kylef/kylef/time 0ed2e79b Fix negative time test to only fail on a single rule 2edc74b1 Add valid time with different second fractions 7bde0bf7 Add valid time with leap second including offset ee83f464 Stricter time format constraints 5732904a Merge pull request #480 from json-schema-org/ether/better-test-names c2994271 better test names for schema-items + additionalItems 6bc53e60 Merge pull request #479 from json-schema-org/fix-non-id-in-enum-for-drafts-6-and-7 3f783d9c fixing draft 6 & 7 non-id tests 5768c68d Merge pull request #476 from json-schema-org/ether/readme-updates 0c8bfc06 add mention of JSON::Schema::Tiny e4c10c6b fix markdown for underscores in package names eeb4db18 mention draft2020-12 in readme dff69dcb Merge pull request #474 from marksparkza/unevaluatedItems-depends-on-contains 51b4977c Merge pull request #478 from sorinsarca/patch-1 dfcd4a19 fix bad comma 4cb100a5 Merge pull request #465 from json-schema-org/ether/more-naive-ref 31dc86bc add another test of naive $ref replacement f858c613 Merge pull request #477 from json-schema-org/ether/more-items-tests 4e266c34 test that array-items/prefixItems adjusts the starting position for schema-items/additionalItems b7fced33 Merge pull request #473 from json-schema-org/ether/more-default-tests eadb9be7 test that a missing property is not populated by the default in the actual instance data 839b95d8 Added opis/json-schema 7cf78800 Add missing comma 3390c871 Update tests/draft2020-12/unevaluatedItems.json d3b88001 Update tests/draft2020-12/unevaluatedItems.json 84e1d5a9 Add another test case for unevaluatedItems-contains interaction f400802c Add tests for unevaluatedItems interaction with contains git-subtree-dir: json git-subtree-split: 09fd353fc44ab22e7e8998d096b3d6d83287e5e6
1 parent 61d6022 commit c19f0b4

25 files changed

+660
-30
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ directory. This is:
6161
## Coverage
6262

6363
Drafts 07, 06, 04, and 03 should have full coverage, with tests for drafts 06,
64-
07, and 2019-09 being considered current and actively supported. Draft 2019-09
65-
is almost fully covered.
64+
07, 2019-09 and 2020-12 being considered current and actively supported.
65+
Drafts 2019-09 and 2020-12 are almost fully covered.
6666

6767
Contributions are very welcome, especially from implementers as they add support
6868
to their own implementations.
@@ -95,11 +95,11 @@ This suite is being used by:
9595

9696
### Dart
9797

98-
* [json_schema](https://github.com/patefacio/json_schema)
98+
* [json\_schema](https://github.com/patefacio/json_schema)
9999

100100
### Elixir
101101

102-
* [ex_json_schema](https://github.com/jonasschmidt/ex_json_schema)
102+
* [ex\_json\_schema](https://github.com/jonasschmidt/ex_json_schema)
103103

104104
### Erlang
105105

@@ -159,17 +159,19 @@ which also welcomes your contributions!
159159
### Perl
160160

161161
* [JSON::Schema::Draft201909](https://github.com/karenetheridge/JSON-Schema-Draft201909)
162+
* [JSON::Schema::Tiny](https://github.com/karenetheridge/JSON-Schema-Tiny)
162163
* [Test::JSON::Schema::Acceptance](https://github.com/karenetheridge/Test-JSON-Schema-Acceptance)
163164

164165
### PHP
165166

167+
* [opis/json-schema](https://github.com/opis/json-schema)
166168
* [json-schema](https://github.com/justinrainbow/json-schema)
167169
* [json-guard](https://github.com/thephpleague/json-guard)
168170

169171
### PostgreSQL
170172

171173
* [postgres-json-schema](https://github.com/gavinwahl/postgres-json-schema)
172-
* [is_jsonb_valid](https://github.com/furstenheim/is_jsonb_valid)
174+
* [is\_jsonb\_valid](https://github.com/furstenheim/is_jsonb_valid)
173175

174176
### Python
175177

@@ -181,7 +183,7 @@ which also welcomes your contributions!
181183
### Ruby
182184

183185
* [json-schema](https://github.com/hoxworth/json-schema)
184-
* [json_schemer](https://github.com/davishmcclurg/json_schemer)
186+
* [json\_schemer](https://github.com/davishmcclurg/json_schemer)
185187

186188
### Rust
187189

tests/draft2019-09/additionalItems.json

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
]
2020
},
2121
{
22-
"description": "items is schema, no additionalItems",
22+
"description": "when items is schema, additionalItems does nothing",
2323
"schema": {
2424
"items": {},
2525
"additionalItems": false
@@ -33,7 +33,7 @@
3333
]
3434
},
3535
{
36-
"description": "array of items with no additionalItems",
36+
"description": "array of items with no additionalItems permitted",
3737
"schema": {
3838
"items": [{}, {}, {}],
3939
"additionalItems": false
@@ -126,5 +126,24 @@
126126
"valid": false
127127
}
128128
]
129+
},
130+
{
131+
"description": "items validation adjusts the starting index for additionalItems",
132+
"schema": {
133+
"items": [ { "type": "string" } ],
134+
"additionalItems": { "type": "integer" }
135+
},
136+
"tests": [
137+
{
138+
"description": "valid items",
139+
"data": [ "x", 2, 3 ],
140+
"valid": true
141+
},
142+
{
143+
"description": "wrong type of second item",
144+
"data": [ "x", "y" ],
145+
"valid": false
146+
}
147+
]
129148
}
130149
]

tests/draft2019-09/default.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,35 @@
4545
"valid": true
4646
}
4747
]
48+
},
49+
{
50+
"description": "the default keyword does not do anything if the property is missing",
51+
"schema": {
52+
"type": "object",
53+
"properties": {
54+
"alpha": {
55+
"type": "number",
56+
"maximum": 3,
57+
"default": 5
58+
}
59+
}
60+
},
61+
"tests": [
62+
{
63+
"description": "an explicit property value is checked against maximum (passing)",
64+
"data": { "alpha": 1 },
65+
"valid": true
66+
},
67+
{
68+
"description": "an explicit property value is checked against maximum (failing)",
69+
"data": { "alpha": 5 },
70+
"valid": false
71+
},
72+
{
73+
"description": "missing properties are not filled in with the default",
74+
"data": {},
75+
"valid": true
76+
}
77+
]
4878
}
4979
]

tests/draft2019-09/optional/format/time.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,84 @@
55
"tests": [
66
{
77
"description": "a valid time string",
8+
"data": "08:30:06Z",
9+
"valid": true
10+
},
11+
{
12+
"description": "a valid time string with leap second",
13+
"data": "23:59:60Z",
14+
"valid": true
15+
},
16+
{
17+
"description": "a valid time string with leap second with offset",
18+
"data": "15:59:60-08:00",
19+
"valid": true
20+
},
21+
{
22+
"description": "a valid time string with second fraction",
23+
"data": "23:20:50.52Z",
24+
"valid": true
25+
},
26+
{
27+
"description": "a valid time string with precise second fraction",
828
"data": "08:30:06.283185Z",
929
"valid": true
1030
},
31+
{
32+
"description": "a valid time string with plus offset",
33+
"data": "08:30:06+00:20",
34+
"valid": true
35+
},
36+
{
37+
"description": "a valid time string with minus offset",
38+
"data": "08:30:06-08:00",
39+
"valid": true
40+
},
41+
{
42+
"description": "a valid time string with case-insensitive Z",
43+
"data": "08:30:06z",
44+
"valid": true
45+
},
46+
{
47+
"description": "an invalid time string with invalid hour",
48+
"data": "24:00:00Z",
49+
"valid": false
50+
},
51+
{
52+
"description": "an invalid time string with invalid minute",
53+
"data": "00:60:00Z",
54+
"valid": false
55+
},
56+
{
57+
"description": "an invalid time string with invalid second",
58+
"data": "00:00:61Z",
59+
"valid": false
60+
},
61+
{
62+
"description": "an invalid time string with invalid leap second (wrong hour)",
63+
"data": "22:59:60Z",
64+
"valid": false
65+
},
66+
{
67+
"description": "an invalid time string with invalid leap second (wrong minute)",
68+
"data": "23:58:60Z",
69+
"valid": false
70+
},
71+
{
72+
"description": "an invalid time string with invalid time numoffset hour",
73+
"data": "01:02:03+24:00",
74+
"valid": false
75+
},
76+
{
77+
"description": "an invalid time string with invalid time numoffset minute",
78+
"data": "01:02:03+00:60",
79+
"valid": false
80+
},
81+
{
82+
"description": "an invalid time string with invalid time with both Z and numoffset",
83+
"data": "01:02:03Z+00:30",
84+
"valid": false
85+
},
1186
{
1287
"description": "an invalid time string",
1388
"data": "08:30:06 PST",

tests/draft2019-09/ref.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,15 @@
420420
},
421421
"tests": [
422422
{
423-
"description": "do not evaluate the $ref inside the enum",
423+
"description": "do not evaluate the $ref inside the enum, matching any string",
424424
"data": "this is a string",
425425
"valid": false
426426
},
427+
{
428+
"description": "do not evaluate the $ref inside the enum, definition exact match",
429+
"data": { "type": "string" },
430+
"valid": false
431+
},
427432
{
428433
"description": "match the enum exactly",
429434
"data": { "$ref": "#/$defs/a_string" },

tests/draft2020-12/default.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,35 @@
4545
"valid": true
4646
}
4747
]
48+
},
49+
{
50+
"description": "the default keyword does not do anything if the property is missing",
51+
"schema": {
52+
"type": "object",
53+
"properties": {
54+
"alpha": {
55+
"type": "number",
56+
"maximum": 3,
57+
"default": 5
58+
}
59+
}
60+
},
61+
"tests": [
62+
{
63+
"description": "an explicit property value is checked against maximum (passing)",
64+
"data": { "alpha": 1 },
65+
"valid": true
66+
},
67+
{
68+
"description": "an explicit property value is checked against maximum (failing)",
69+
"data": { "alpha": 5 },
70+
"valid": false
71+
},
72+
{
73+
"description": "missing properties are not filled in with the default",
74+
"data": {},
75+
"valid": true
76+
}
77+
]
4878
}
4979
]

tests/draft2020-12/items.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,24 @@
233233
"valid": true
234234
}
235235
]
236+
},
237+
{
238+
"description": "prefixItems validation adjusts the starting index for items",
239+
"schema": {
240+
"prefixItems": [ { "type": "string" } ],
241+
"items": { "type": "integer" }
242+
},
243+
"tests": [
244+
{
245+
"description": "valid items",
246+
"data": [ "x", 2, 3 ],
247+
"valid": true
248+
},
249+
{
250+
"description": "wrong type of second item",
251+
"data": [ "x", "y" ],
252+
"valid": false
253+
}
254+
]
236255
}
237256
]

tests/draft2020-12/optional/format/time.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,84 @@
55
"tests": [
66
{
77
"description": "a valid time string",
8+
"data": "08:30:06Z",
9+
"valid": true
10+
},
11+
{
12+
"description": "a valid time string with leap second",
13+
"data": "23:59:60Z",
14+
"valid": true
15+
},
16+
{
17+
"description": "a valid time string with leap second with offset",
18+
"data": "15:59:60-08:00",
19+
"valid": true
20+
},
21+
{
22+
"description": "a valid time string with second fraction",
23+
"data": "23:20:50.52Z",
24+
"valid": true
25+
},
26+
{
27+
"description": "a valid time string with precise second fraction",
828
"data": "08:30:06.283185Z",
929
"valid": true
1030
},
31+
{
32+
"description": "a valid time string with plus offset",
33+
"data": "08:30:06+00:20",
34+
"valid": true
35+
},
36+
{
37+
"description": "a valid time string with minus offset",
38+
"data": "08:30:06-08:00",
39+
"valid": true
40+
},
41+
{
42+
"description": "a valid time string with case-insensitive Z",
43+
"data": "08:30:06z",
44+
"valid": true
45+
},
46+
{
47+
"description": "an invalid time string with invalid hour",
48+
"data": "24:00:00Z",
49+
"valid": false
50+
},
51+
{
52+
"description": "an invalid time string with invalid minute",
53+
"data": "00:60:00Z",
54+
"valid": false
55+
},
56+
{
57+
"description": "an invalid time string with invalid second",
58+
"data": "00:00:61Z",
59+
"valid": false
60+
},
61+
{
62+
"description": "an invalid time string with invalid leap second (wrong hour)",
63+
"data": "22:59:60Z",
64+
"valid": false
65+
},
66+
{
67+
"description": "an invalid time string with invalid leap second (wrong minute)",
68+
"data": "23:58:60Z",
69+
"valid": false
70+
},
71+
{
72+
"description": "an invalid time string with invalid time numoffset hour",
73+
"data": "01:02:03+24:00",
74+
"valid": false
75+
},
76+
{
77+
"description": "an invalid time string with invalid time numoffset minute",
78+
"data": "01:02:03+00:60",
79+
"valid": false
80+
},
81+
{
82+
"description": "an invalid time string with invalid time with both Z and numoffset",
83+
"data": "01:02:03Z+00:30",
84+
"valid": false
85+
},
1186
{
1287
"description": "an invalid time string",
1388
"data": "08:30:06 PST",

tests/draft2020-12/ref.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,10 +422,15 @@
422422
},
423423
"tests": [
424424
{
425-
"description": "do not evaluate the $ref inside the enum",
425+
"description": "do not evaluate the $ref inside the enum, matching any string",
426426
"data": "this is a string",
427427
"valid": false
428428
},
429+
{
430+
"description": "do not evaluate the $ref inside the enum, definition exact match",
431+
"data": { "type": "string" },
432+
"valid": false
433+
},
429434
{
430435
"description": "match the enum exactly",
431436
"data": { "$ref": "#/$defs/a_string" },

0 commit comments

Comments
 (0)