Skip to content

Commit 7bc357f

Browse files
committed
Change "expected" to an object with schema locations
1 parent 265103e commit 7bc357f

9 files changed

+245
-134
lines changed

annotations/README.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22

33
The Annotations Test Suite tests which annotations should appear (or not appear)
44
on which values of an instance. These tests are agnostic of any output format.
5-
Similar to the validation tests, they only test the end result and don't include
6-
details like mapping the annotation back to the schema location that contributed
7-
it. This Test Suite leaves those details to be tested by output format tests.
85

96
## Supported Dialects
107

11-
Although the concept of annotations didn't appear in the spec until 2019-09, the
12-
concept is compatible with every version of JSON Schema. Test Cases in this Test
13-
Suite are designed to be compatible with as many releases of JSON Schema as
14-
possible. They do not include `$schema` or `$id`/`id` keywords so that
8+
Although the annotation terminology of didn't appear in the spec until 2019-09,
9+
the concept is compatible with every version of JSON Schema. Test Cases in this
10+
Test Suite are designed to be compatible with as many releases of JSON Schema as
11+
possible. They do not include `$schema` or `$id`/`id` keywords so
1512
implementations can run the same Test Suite for each dialect they support.
1613

1714
Since this Test Suite can be used for a variety of dialects, there are a couple
@@ -28,7 +25,7 @@ A short description of what behavior the Test Case is covering.
2825

2926
The `compatibility` option allows you to set which dialects the Test Case is
3027
compatible with. Test Runners can use this value to filter out Test Cases that
31-
don't apply the to dialect currently under test. The concept of annotations
28+
don't apply the to dialect currently under test. The terminology for annotations
3229
didn't appear in the spec until 2019-09, but the concept is compatible with
3330
older releases as well. When setting `compatibility`, test authors should take
3431
into account dialects before 2019-09 for implementations that chose to support
@@ -104,13 +101,16 @@ The annotating keyword.
104101

105102
### expected
106103

107-
An array of `keyword` annotations expected on the instance at `location`.
108-
`expected` is an array because there's always a chance that an annotation is
109-
applied multiple times to any given instance location. An empty array is an
110-
assertion that the annotation must not appear at the `location` for the
111-
`keyword`.
104+
A collection of `keyword` annotations expected on the instance at `location`.
105+
`expected` is an object where the keys are schema locations and the values are
106+
the annotation that schema location contributed for the given `keyword`.
112107

113-
Test runners can consider this an unordered list, but as a convention for this
114-
Test Suite, the `expected` array should be sorted such that the most recently
115-
encountered value for an annotation given top-down evaluation of the schema
116-
comes before previously encountered values.
108+
There can be more than one expected annotation because multiple schema locations
109+
could contribute annotations for a single keyword.
110+
111+
An empty object is an assertion that the annotation must not appear at the
112+
`location` for the `keyword`.
113+
114+
As a convention for this Test Suite, the `expected` array should be sorted such
115+
that the most recently encountered value for an annotation given top-down
116+
evaluation of the schema comes before previously encountered values.

annotations/assertion.schema.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
},
1515
"expected": {
1616
"markdownDescription": "An array of `keyword` annotations expected on the instance at `location`.",
17-
"type": "array"
17+
"type": "object",
18+
"propertyNames": {
19+
"format": "uri"
20+
}
1821
}
1922
},
2023
"required": ["location", "keyword", "expected"]

annotations/tests/applicators.json

+57-57
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@
2727
{
2828
"location": "/foo",
2929
"keyword": "title",
30-
"expected": []
30+
"expected": {}
3131
},
3232
{
3333
"location": "/apple",
3434
"keyword": "title",
35-
"expected": []
35+
"expected": {}
3636
},
3737
{
3838
"location": "/bar",
3939
"keyword": "title",
40-
"expected": []
40+
"expected": {}
4141
}
4242
]
4343
},
@@ -51,23 +51,23 @@
5151
{
5252
"location": "/foo",
5353
"keyword": "title",
54-
"expected": [
55-
"Foo"
56-
]
54+
"expected": {
55+
"#/properties/foo": "Foo"
56+
}
5757
},
5858
{
5959
"location": "/apple",
6060
"keyword": "title",
61-
"expected": [
62-
"Bar"
63-
]
61+
"expected": {
62+
"#/patternProperties/%5Ea": "Bar"
63+
}
6464
},
6565
{
6666
"location": "/baz",
6767
"keyword": "title",
68-
"expected": [
69-
"Baz"
70-
]
68+
"expected": {
69+
"#/additionalProperties": "Baz"
70+
}
7171
}
7272
]
7373
}
@@ -91,7 +91,7 @@
9191
{
9292
"location": "/foo",
9393
"keyword": "title",
94-
"expected": []
94+
"expected": {}
9595
}
9696
]
9797
}
@@ -120,21 +120,21 @@
120120
{
121121
"location": "/0",
122122
"keyword": "title",
123-
"expected": [
124-
"Foo"
125-
]
123+
"expected": {
124+
"#/prefixItems/0": "Foo"
125+
}
126126
},
127127
{
128128
"location": "/1",
129129
"keyword": "title",
130-
"expected": [
131-
"Bar"
132-
]
130+
"expected": {
131+
"#/items": "Bar"
132+
}
133133
},
134134
{
135135
"location": "/2",
136136
"keyword": "title",
137-
"expected": []
137+
"expected": {}
138138
}
139139
]
140140
}
@@ -160,24 +160,24 @@
160160
{
161161
"location": "/0",
162162
"keyword": "title",
163-
"expected": []
163+
"expected": {}
164164
},
165165
{
166166
"location": "/1",
167167
"keyword": "title",
168-
"expected": [
169-
"Foo"
170-
]
168+
"expected": {
169+
"#/contains": "Foo"
170+
}
171171
},
172172
{
173173
"location": "/2",
174174
"keyword": "title",
175-
"expected": []
175+
"expected": {}
176176
},
177177
{
178178
"location": "/3",
179179
"keyword": "title",
180-
"expected": []
180+
"expected": {}
181181
}
182182
]
183183
}
@@ -203,10 +203,10 @@
203203
{
204204
"location": "",
205205
"keyword": "title",
206-
"expected": [
207-
"Bar",
208-
"Foo"
209-
]
206+
"expected": {
207+
"#/allOf/1": "Bar",
208+
"#/allOf/0": "Foo"
209+
}
210210
}
211211
]
212212
}
@@ -234,10 +234,10 @@
234234
{
235235
"location": "",
236236
"keyword": "title",
237-
"expected": [
238-
"Bar",
239-
"Foo"
240-
]
237+
"expected": {
238+
"#/anyOf/1": "Bar",
239+
"#/anyOf/0": "Foo"
240+
}
241241
}
242242
]
243243
},
@@ -247,9 +247,9 @@
247247
{
248248
"location": "",
249249
"keyword": "title",
250-
"expected": [
251-
"Bar"
252-
]
250+
"expected": {
251+
"#/anyOf/1": "Bar"
252+
}
253253
}
254254
]
255255
}
@@ -277,9 +277,9 @@
277277
{
278278
"location": "",
279279
"keyword": "title",
280-
"expected": [
281-
"Foo"
282-
]
280+
"expected": {
281+
"#/oneOf/0": "Foo"
282+
}
283283
}
284284
]
285285
},
@@ -289,9 +289,9 @@
289289
{
290290
"location": "",
291291
"keyword": "title",
292-
"expected": [
293-
"Bar"
294-
]
292+
"expected": {
293+
"#/oneOf/1": "Bar"
294+
}
295295
}
296296
]
297297
}
@@ -315,9 +315,9 @@
315315
{
316316
"location": "",
317317
"keyword": "title",
318-
"expected": [
319-
"Foo"
320-
]
318+
"expected": {
319+
"#": "Foo"
320+
}
321321
}
322322
]
323323
}
@@ -342,9 +342,9 @@
342342
{
343343
"location": "",
344344
"keyword": "title",
345-
"expected": [
346-
"Foo"
347-
]
345+
"expected": {
346+
"#/dependentSchemas/foo": "Foo"
347+
}
348348
}
349349
]
350350
},
@@ -356,7 +356,7 @@
356356
{
357357
"location": "/foo",
358358
"keyword": "title",
359-
"expected": []
359+
"expected": {}
360360
}
361361
]
362362
}
@@ -384,10 +384,10 @@
384384
{
385385
"location": "",
386386
"keyword": "title",
387-
"expected": [
388-
"Then",
389-
"If"
390-
]
387+
"expected": {
388+
"#/then": "Then",
389+
"#/if": "If"
390+
}
391391
}
392392
]
393393
},
@@ -397,9 +397,9 @@
397397
{
398398
"location": "",
399399
"keyword": "title",
400-
"expected": [
401-
"Else"
402-
]
400+
"expected": {
401+
"#/else": "Else"
402+
}
403403
}
404404
]
405405
}

annotations/tests/content.json

+13-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
{
1616
"location": "",
1717
"keyword": "contentMediaType",
18-
"expected": ["application/json"]
18+
"expected": {
19+
"#": "application/json"
20+
}
1921
}
2022
]
2123
},
@@ -25,7 +27,7 @@
2527
{
2628
"location": "",
2729
"keyword": "contentMediaType",
28-
"expected": []
30+
"expected": {}
2931
}
3032
]
3133
}
@@ -44,7 +46,9 @@
4446
{
4547
"location": "",
4648
"keyword": "contentEncoding",
47-
"expected": ["base64"]
49+
"expected": {
50+
"#": "base64"
51+
}
4852
}
4953
]
5054
},
@@ -54,7 +58,7 @@
5458
{
5559
"location": "",
5660
"keyword": "contentEncoding",
57-
"expected": []
61+
"expected": {}
5862
}
5963
]
6064
}
@@ -75,7 +79,9 @@
7579
{
7680
"location": "",
7781
"keyword": "contentSchema",
78-
"expected": [{ "type": "number" }]
82+
"expected": {
83+
"#": { "type": "number" }
84+
}
7985
}
8086
]
8187
},
@@ -85,7 +91,7 @@
8591
{
8692
"location": "",
8793
"keyword": "contentSchema",
88-
"expected": []
94+
"expected": {}
8995
}
9096
]
9197
}
@@ -105,7 +111,7 @@
105111
{
106112
"location": "",
107113
"keyword": "contentSchema",
108-
"expected": []
114+
"expected": {}
109115
}
110116
]
111117
}

0 commit comments

Comments
 (0)