Skip to content

Commit 9300b61

Browse files
authored
Merge branch 'main' into feat/draft2020-12-maxcontains-zero
2 parents 457a2bd + 54ed4d1 commit 9300b61

41 files changed

Lines changed: 1549 additions & 67 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ These are:
8686

8787
1. `optional/`: Contains tests that are considered optional. Note that this subdirectory currently conflates many reasons why a test may be optional -- it may be because tests within a particular file are indeed not required by the specification but still potentially useful to an implementer, or it may be because tests within it only apply to programming languages with particular functionality (in which case they are not truly optional in such a language). In the future this directory structure will be made richer to reflect these differences more clearly.
8888

89-
2. `proposals/`: Contains a subfolder for each active proposal to the specification. If the proposal is a keyword (generally the case), then the subfolder will bear the name of that keyword. Inside the proposal subfolder is a series of test files that would contain amendments to the required test suite should the proposal be incorporated into the specification. These test should be considered volitile while the proposal is in development, however implementations claiming to support the proposal are expected to pass its tests.
89+
2. `proposals/`: Contains a subfolder for each active proposal to the specification. If the proposal is a keyword (generally the case), then the subfolder will bear the name of that keyword. Inside the proposal subfolder is a series of test files that would contain amendments to the required test suite should the proposal be incorporated into the specification. These tests should be considered volatile while the proposal is in development; however, implementations claiming to support the proposal are expected to pass its tests.
9090

9191
## Using the Suite to Test a Validator Implementation
9292

annotations/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on which values of an instance. These tests are agnostic of any output format.
55

66
## Supported Dialects
77

8-
Although the annotation terminology of didn't appear in the spec until 2019-09,
8+
Although annotation terminology didn't appear in the spec until 2019-09,
99
the concept is compatible with every version of JSON Schema. Test Cases in this
1010
Test Suite are designed to be compatible with as many releases of JSON Schema as
1111
possible. They do not include `$schema` or `$id`/`id` keywords so
@@ -25,7 +25,7 @@ A short description of what behavior the Test Case is covering.
2525

2626
The `compatibility` option allows you to set which dialects the Test Case is
2727
compatible with. Test Runners can use this value to filter out Test Cases that
28-
don't apply the to dialect currently under test. The terminology for annotations
28+
don't apply to the dialect currently under test. The terminology for annotations
2929
didn't appear in the spec until 2019-09, but the concept is compatible with
3030
older releases as well. When setting `compatibility`, test authors should take
3131
into account dialects before 2019-09 for implementations that chose to support
@@ -42,7 +42,7 @@ Case is compatible with draft-07 and up.
4242
**Example**: `"compatibility": "7"`
4343

4444
You can use a `<=` operator to indicate that the Test Case is compatible with
45-
releases less then or equal to the given release. This example indicates that
45+
releases less than or equal to the given release. This example indicates that
4646
the Test Case is compatible with 2019-09 and under.
4747

4848
**Example**: `"compatibility": "<=2019"`
@@ -111,6 +111,6 @@ could contribute annotations for a single keyword.
111111
An empty object is an assertion that the annotation must not appear at the
112112
`location` for the `keyword`.
113113

114-
As a convention for this Test Suite, the `expected` array should be sorted such
114+
As a convention for this Test Suite, the `expected` object should be sorted such
115115
that the most recently encountered value for an annotation given top-down
116116
evaluation of the schema comes before previously encountered values.

annotations/test-case.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"pattern": "^(<=|=)?([123467]|2019|2020)(,(<=|=)?([123467]|2019|2020))*$"
1414
},
1515
"schema": {
16-
"markdownDescription": "This schema shouldn't include `$schema` or `id`/`$id` unless necesary for the test because Test Cases should be designed to work with as many releases as possible.",
16+
"markdownDescription": "This schema shouldn't include `$schema` or `id`/`$id` unless necessary for the test because Test Cases should be designed to work with as many releases as possible.",
1717
"type": ["boolean", "object"]
1818
},
1919
"externalSchemas": {

annotations/tests/core.json

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,108 @@
2525
]
2626
}
2727
]
28+
},
29+
{
30+
"description": "`$dynamicRef` resolves to `$dynamicAnchor`",
31+
"compatibility": "2020",
32+
"schema": {
33+
"$dynamicRef": "#foo",
34+
"$defs": {
35+
"foo": {
36+
"$dynamicAnchor": "foo",
37+
"title": "Foo"
38+
}
39+
}
40+
},
41+
"tests": [
42+
{
43+
"instance": "bar",
44+
"assertions": [
45+
{
46+
"location": "",
47+
"keyword": "title",
48+
"expected": {
49+
"#/$defs/foo": "Foo"
50+
}
51+
}
52+
]
53+
}
54+
]
55+
},
56+
{
57+
"description": "`$dynamicRef` resolves to different `$dynamicAnchor`s depending on dynamic path",
58+
"compatibility": "2020",
59+
"schema": {
60+
"$id": "https://test.json-schema.org/dynamic-ref-annotation/main",
61+
"if": {
62+
"properties": { "kindOfList": { "const": "numbers" } },
63+
"required": ["kindOfList"]
64+
},
65+
"then": { "$ref": "numberList" },
66+
"else": { "$ref": "stringList" },
67+
"$defs": {
68+
"genericList": {
69+
"$id": "genericList",
70+
"properties": {
71+
"list": {
72+
"items": { "$dynamicRef": "#itemType" }
73+
}
74+
},
75+
"$defs": {
76+
"defaultItemType": {
77+
"$dynamicAnchor": "itemType"
78+
}
79+
}
80+
},
81+
"numberList": {
82+
"$id": "numberList",
83+
"$defs": {
84+
"itemType": {
85+
"$dynamicAnchor": "itemType",
86+
"title": "Number Item"
87+
}
88+
},
89+
"$ref": "genericList"
90+
},
91+
"stringList": {
92+
"$id": "stringList",
93+
"$defs": {
94+
"itemType": {
95+
"$dynamicAnchor": "itemType",
96+
"title": "String Item"
97+
}
98+
},
99+
"$ref": "genericList"
100+
}
101+
}
102+
},
103+
"tests": [
104+
{
105+
"instance": { "kindOfList": "numbers", "list": [1] },
106+
"assertions": [
107+
{
108+
"location": "/list/0",
109+
"keyword": "title",
110+
"expected": {
111+
"#/$defs/numberList/$defs/itemType": "Number Item"
112+
}
113+
}
114+
]
115+
},
116+
{
117+
"instance": { "kindOfList": "strings", "list": ["foo"] },
118+
"assertions": [
119+
{
120+
"location": "/list/0",
121+
"keyword": "title",
122+
"expected": {
123+
"#/$defs/stringList/$defs/itemType": "String Item"
124+
}
125+
}
126+
]
127+
}
128+
]
28129
}
130+
29131
]
30-
}
132+
}

bin/jsonschema_suite

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ class SanityTests(unittest.TestCase):
281281
"$vocabulary",
282282
"additionalProperties",
283283
"allOf",
284-
"allOf",
285284
"anyOf",
286285
"const",
287286
"contains",
@@ -301,7 +300,6 @@ class SanityTests(unittest.TestCase):
301300
"items",
302301
"maxContains",
303302
"maxItems",
304-
"maxItems",
305303
"maxLength",
306304
"maxProperties",
307305
"maximum",

output-tests/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ _**NOTE** Although the formats didn't change much between 2019-09 and 2020-12, t
88

99
The tests are organized by specification release and then into two categories: content and structure.
1010

11-
Content tests verify that the keywords are producing the correct annotations and/or error messages. Since there are no requirements on the content of error messages, there's not much that can be verified for them, but it is possible to identify when a error message _could_ be present. Primarily, these tests need to extensively cover the annotation behaviors of each keyword. The only output format needed for these tests is `basic` for 2019-09/2020-12 and `list` for later versions.
11+
Content tests verify that the keywords are producing the correct annotations and/or error messages. Since there are no requirements on the content of error messages, there's not much that can be verified for them, but it is possible to identify when an error message _could_ be present. Primarily, these tests need to extensively cover the annotation behaviors of each keyword. The only output format needed for these tests is `basic` for 2019-09/2020-12 and `list` for later versions.
1212

1313
Structure tests verify that the structures of the various formats (i.e. `flag`, `basic`, `detailed`, `verbose` for 2019-09/2020-12 and `flag`, `list`, `hierarchical` for later versions) are correct. These tests don't need to cover each keyword; rather they need to sufficiently cover the various aspects of building the output structures by using whatever keywords are necessary to do so.
1414

@@ -22,7 +22,7 @@ The `output` property itself has a property for each of the output formats where
2222

2323
## Other notes
2424

25-
### Ambiguity around 2020-09/2020-12 `basic`
25+
### Ambiguity around 2019-09/2020-12 `basic`
2626

2727
The 2019-09/2020-12 specs don't define the structure of `basic` very thoroughly. Specifically there is a nuance where if the list contains a single output node, there are two possible structures, given the text:
2828

tests/draft2019-09/enum.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,5 +354,44 @@
354354
"valid": false
355355
}
356356
]
357+
},
358+
{
359+
"description": "empty enum",
360+
"schema": {
361+
"$schema": "https://json-schema.org/draft/2019-09/schema",
362+
"enum": []
363+
},
364+
"tests": [
365+
{
366+
"description": "string is invalid",
367+
"data": "foo",
368+
"valid": false
369+
},
370+
{
371+
"description": "number is invalid",
372+
"data": 42,
373+
"valid": false
374+
},
375+
{
376+
"description": "null is invalid",
377+
"data": null,
378+
"valid": false
379+
},
380+
{
381+
"description": "object is invalid",
382+
"data": {},
383+
"valid": false
384+
},
385+
{
386+
"description": "array is invalid",
387+
"data": [],
388+
"valid": false
389+
},
390+
{
391+
"description": "boolean is invalid",
392+
"data": false,
393+
"valid": false
394+
}
395+
]
357396
}
358397
]

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

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[
22
{
33
"description": "validation of duration strings",
4+
"comment": "RFC 3339 Appendix A defines the ABNF grammar for ISO-8601 durations used by JSON Schema format 'duration'. These tests enforce only the syntax defined by that grammar.",
45
"schema": {
56
"$schema": "https://json-schema.org/draft/2019-09/schema",
67
"format": "duration"
@@ -135,6 +136,87 @@
135136
"description": "element without unit",
136137
"data": "P1",
137138
"valid": false
139+
},
140+
{
141+
"description": "all date and time components",
142+
"data": "P1Y2M3DT4H5M6S",
143+
"valid": true
144+
},
145+
{
146+
"description": "date components only",
147+
"data": "P1Y2M3D",
148+
"valid": true
149+
},
150+
{
151+
"description": "time components only",
152+
"data": "PT1H2M3S",
153+
"valid": true
154+
},
155+
{
156+
"description": "month and day",
157+
"data": "P1M2D",
158+
"valid": true
159+
},
160+
{
161+
"description": "hour and minute",
162+
"data": "PT1H30M",
163+
"valid": true
164+
},
165+
{
166+
"description": "multi-digit values in all components",
167+
"data": "P10Y10M10DT10H10M10S",
168+
"valid": true
169+
},
170+
{
171+
"description": "fractional duration is not allowed by RFC 3339 ABNF",
172+
"comment": "numeric components use 1*DIGIT where DIGIT = %x30-39; '.' is not allowed",
173+
"data": "PT0.5S",
174+
"valid": false
175+
},
176+
{
177+
"description": "leading whitespace is invalid",
178+
"data": " P1D",
179+
"valid": false
180+
},
181+
{
182+
"description": "trailing whitespace is invalid",
183+
"data": "P1D ",
184+
"valid": false
185+
},
186+
{
187+
"description": "empty string is invalid",
188+
"data": "",
189+
"valid": false
190+
},
191+
{
192+
"description": "years and months can appear without days",
193+
"data": "P1Y2M",
194+
"valid": true
195+
},
196+
{
197+
"description": "years and days cannot appear without months",
198+
"data": "P1Y2D",
199+
"valid": false
200+
},
201+
{
202+
"description": "months and days can appear without years",
203+
"data": "P1M2D",
204+
"valid": true
205+
},
206+
{
207+
"description": "hours and minutes can appear without seconds",
208+
"data": "PT1H2M",
209+
"valid": true
210+
},
211+
{
212+
"description": "hours and seconds cannot appear without minutes",
213+
"data": "PT1H2S",
214+
"valid": false
215+
},
216+
{
217+
"description": "minutes and seconds can appear without hour",
218+
"data": "PT1M2S",
219+
"valid": true
138220
}
139221
]
140222
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,21 @@
9090
"description": "full \"From\" header is invalid",
9191
"data": "\"Winston Smith\" <winston.smith@recdep.minitrue> (Records Department)",
9292
"valid": false
93+
},
94+
{
95+
"description": "local part is required",
96+
"data": "@example.com",
97+
"valid": false
98+
},
99+
{
100+
"description": "domain is required",
101+
"data": "joe.bloggs@",
102+
"valid": false
103+
},
104+
{
105+
"description": "unquoted space in local part is invalid",
106+
"data": "joe bloggs@example.com",
107+
"valid": false
93108
}
94109
]
95110
}

0 commit comments

Comments
 (0)