@hyperjump/json-schema 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.md +116 -5
  2. package/annotations/annotated-instance.d.ts +83 -0
  3. package/annotations/annotated-instance.js +50 -0
  4. package/annotations/index.d.ts +11 -0
  5. package/annotations/index.js +123 -0
  6. package/annotations/tests/applicators.json +375 -0
  7. package/annotations/tests/content.json +60 -0
  8. package/annotations/tests/core.json +33 -0
  9. package/annotations/tests/format.json +21 -0
  10. package/annotations/tests/meta-data.json +135 -0
  11. package/annotations/tests/unevaluated.json +557 -0
  12. package/annotations/tests/unknown.json +91 -0
  13. package/annotations/tests/validation.json +328 -0
  14. package/annotations/validation-error.d.ts +8 -0
  15. package/annotations/validation-error.js +7 -0
  16. package/bundle/index.js +2 -3
  17. package/lib/keywords/additionalProperties.js +19 -4
  18. package/lib/keywords/allOf.js +2 -2
  19. package/lib/keywords/anyOf.js +2 -2
  20. package/lib/keywords/contains.js +14 -14
  21. package/lib/keywords/contentSchema.js +7 -2
  22. package/lib/keywords/dependentSchemas.js +18 -8
  23. package/lib/keywords/dynamicRef.js +2 -2
  24. package/lib/keywords/else.js +12 -19
  25. package/lib/keywords/if.js +2 -2
  26. package/lib/keywords/items.js +3 -3
  27. package/lib/keywords/not.js +1 -1
  28. package/lib/keywords/oneOf.js +2 -2
  29. package/lib/keywords/patternProperties.js +20 -3
  30. package/lib/keywords/prefixItems.js +3 -3
  31. package/lib/keywords/properties.js +18 -6
  32. package/lib/keywords/propertyDependencies.js +2 -2
  33. package/lib/keywords/propertyNames.js +1 -1
  34. package/lib/keywords/then.js +12 -19
  35. package/lib/keywords/unevaluatedItems.js +2 -2
  36. package/lib/keywords/unevaluatedProperties.js +25 -5
  37. package/lib/keywords/validation.js +43 -53
  38. package/lib/keywords.js +1 -1
  39. package/package.json +4 -2
@@ -0,0 +1,557 @@
1
+ [
2
+ {
3
+ "title": "`unevaluatedProperties` alone",
4
+ "schema": {
5
+ "unevaluatedProperties": { "title": "Unevaluated" }
6
+ },
7
+ "subjects": [
8
+ {
9
+ "instance": { "foo": 42, "bar": 24 },
10
+ "assertions": [
11
+ {
12
+ "location": "#/foo",
13
+ "keyword": "title",
14
+ "expected": ["Unevaluated"]
15
+ },
16
+ {
17
+ "location": "#/bar",
18
+ "keyword": "title",
19
+ "expected": ["Unevaluated"]
20
+ }
21
+ ]
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "title": "`unevaluatedProperties` with `properties`",
27
+ "schema": {
28
+ "properties": {
29
+ "foo": { "title": "Evaluated" }
30
+ },
31
+ "unevaluatedProperties": { "title": "Unevaluated" }
32
+ },
33
+ "subjects": [
34
+ {
35
+ "instance": { "foo": 42, "bar": 24 },
36
+ "assertions": [
37
+ {
38
+ "location": "#/foo",
39
+ "keyword": "title",
40
+ "expected": ["Evaluated"]
41
+ },
42
+ {
43
+ "location": "#/bar",
44
+ "keyword": "title",
45
+ "expected": ["Unevaluated"]
46
+ }
47
+ ]
48
+ }
49
+ ]
50
+ },
51
+ {
52
+ "title": "`unevaluatedProperties` with `patternProperties`",
53
+ "schema": {
54
+ "patternProperties": {
55
+ "^a": { "title": "Evaluated" }
56
+ },
57
+ "unevaluatedProperties": { "title": "Unevaluated" }
58
+ },
59
+ "subjects": [
60
+ {
61
+ "instance": { "apple": 42, "bar": 24 },
62
+ "assertions": [
63
+ {
64
+ "location": "#/apple",
65
+ "keyword": "title",
66
+ "expected": ["Evaluated"]
67
+ },
68
+ {
69
+ "location": "#/bar",
70
+ "keyword": "title",
71
+ "expected": ["Unevaluated"]
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ },
77
+ {
78
+ "title": "`unevaluatedProperties` with `additionalProperties`",
79
+ "schema": {
80
+ "additionalProperties": { "title": "Evaluated" },
81
+ "unevaluatedProperties": { "title": "Unevaluated" }
82
+ },
83
+ "subjects": [
84
+ {
85
+ "instance": { "foo": 42, "bar": 24 },
86
+ "assertions": [
87
+ {
88
+ "location": "#/foo",
89
+ "keyword": "title",
90
+ "expected": ["Evaluated"]
91
+ },
92
+ {
93
+ "location": "#/bar",
94
+ "keyword": "title",
95
+ "expected": ["Evaluated"]
96
+ }
97
+ ]
98
+ }
99
+ ]
100
+ },
101
+ {
102
+ "title": "`unevaluatedProperties` with `dependentSchemas`",
103
+ "schema": {
104
+ "dependentSchemas": {
105
+ "foo": {
106
+ "properties": {
107
+ "bar": { "title": "Evaluated" }
108
+ }
109
+ }
110
+ },
111
+ "unevaluatedProperties": { "title": "Unevaluated" }
112
+ },
113
+ "subjects": [
114
+ {
115
+ "instance": { "foo": 42, "bar": 24 },
116
+ "assertions": [
117
+ {
118
+ "location": "#/foo",
119
+ "keyword": "title",
120
+ "expected": ["Unevaluated"]
121
+ },
122
+ {
123
+ "location": "#/bar",
124
+ "keyword": "title",
125
+ "expected": ["Evaluated"]
126
+ }
127
+ ]
128
+ }
129
+ ]
130
+ },
131
+ {
132
+ "title": "`unevaluatedProperties` with `if`, `then`, and `else`",
133
+ "schema": {
134
+ "if": {
135
+ "properties": {
136
+ "foo": {
137
+ "type": "string",
138
+ "title": "If"
139
+ }
140
+ }
141
+ },
142
+ "then": {
143
+ "properties": {
144
+ "foo": { "title": "Then" }
145
+ }
146
+ },
147
+ "else": {
148
+ "properties": {
149
+ "foo": { "title": "Else" }
150
+ }
151
+ },
152
+ "unevaluatedProperties": { "title": "Unevaluated" }
153
+ },
154
+ "subjects": [
155
+ {
156
+ "instance": { "foo": "", "bar": 42 },
157
+ "assertions": [
158
+ {
159
+ "location": "#/foo",
160
+ "keyword": "title",
161
+ "expected": ["Then", "If"]
162
+ },
163
+ {
164
+ "location": "#/bar",
165
+ "keyword": "title",
166
+ "expected": ["Unevaluated"]
167
+ }
168
+ ]
169
+ },
170
+ {
171
+ "instance": { "foo": 42, "bar": "" },
172
+ "assertions": [
173
+ {
174
+ "location": "#/foo",
175
+ "keyword": "title",
176
+ "expected": ["Else"]
177
+ },
178
+ {
179
+ "location": "#/bar",
180
+ "keyword": "title",
181
+ "expected": ["Unevaluated"]
182
+ }
183
+ ]
184
+ }
185
+ ]
186
+ },
187
+ {
188
+ "title": "`unevaluatedProperties` with `allOf`",
189
+ "schema": {
190
+ "allOf": [
191
+ {
192
+ "properties": {
193
+ "foo": { "title": "Evaluated" }
194
+ }
195
+ }
196
+ ],
197
+ "unevaluatedProperties": { "title": "Unevaluated" }
198
+ },
199
+ "subjects": [
200
+ {
201
+ "instance": { "foo": 42, "bar": 24 },
202
+ "assertions": [
203
+ {
204
+ "location": "#/foo",
205
+ "keyword": "title",
206
+ "expected": ["Evaluated"]
207
+ },
208
+ {
209
+ "location": "#/bar",
210
+ "keyword": "title",
211
+ "expected": ["Unevaluated"]
212
+ }
213
+ ]
214
+ }
215
+ ]
216
+ },
217
+ {
218
+ "title": "`unevaluatedProperties` with `anyOf`",
219
+ "schema": {
220
+ "anyOf": [
221
+ {
222
+ "properties": {
223
+ "foo": { "title": "Evaluated" }
224
+ }
225
+ }
226
+ ],
227
+ "unevaluatedProperties": { "title": "Unevaluated" }
228
+ },
229
+ "subjects": [
230
+ {
231
+ "instance": { "foo": 42, "bar": 24 },
232
+ "assertions": [
233
+ {
234
+ "location": "#/foo",
235
+ "keyword": "title",
236
+ "expected": ["Evaluated"]
237
+ },
238
+ {
239
+ "location": "#/bar",
240
+ "keyword": "title",
241
+ "expected": ["Unevaluated"]
242
+ }
243
+ ]
244
+ }
245
+ ]
246
+ },
247
+ {
248
+ "title": "`unevaluatedProperties` with `oneOf`",
249
+ "schema": {
250
+ "oneOf": [
251
+ {
252
+ "properties": {
253
+ "foo": { "title": "Evaluated" }
254
+ }
255
+ }
256
+ ],
257
+ "unevaluatedProperties": { "title": "Unevaluated" }
258
+ },
259
+ "subjects": [
260
+ {
261
+ "instance": { "foo": 42, "bar": 24 },
262
+ "assertions": [
263
+ {
264
+ "location": "#/foo",
265
+ "keyword": "title",
266
+ "expected": ["Evaluated"]
267
+ },
268
+ {
269
+ "location": "#/bar",
270
+ "keyword": "title",
271
+ "expected": ["Unevaluated"]
272
+ }
273
+ ]
274
+ }
275
+ ]
276
+ },
277
+ {
278
+ "title": "`unevaluatedProperties` with `not`",
279
+ "schema": {
280
+ "not": {
281
+ "not": {
282
+ "properties": {
283
+ "foo": { "title": "Evaluated" }
284
+ }
285
+ }
286
+ },
287
+ "unevaluatedProperties": { "title": "Unevaluated" }
288
+ },
289
+ "subjects": [
290
+ {
291
+ "instance": { "foo": 42, "bar": 24 },
292
+ "assertions": [
293
+ {
294
+ "location": "#/foo",
295
+ "keyword": "title",
296
+ "expected": ["Unevaluated"]
297
+ },
298
+ {
299
+ "location": "#/bar",
300
+ "keyword": "title",
301
+ "expected": ["Unevaluated"]
302
+ }
303
+ ]
304
+ }
305
+ ]
306
+ },
307
+ {
308
+ "title": "`unevaluatedItems` alone",
309
+ "schema": {
310
+ "unevaluatedItems": { "title": "Unevaluated" }
311
+ },
312
+ "subjects": [
313
+ {
314
+ "instance": [42, 24],
315
+ "assertions": [
316
+ {
317
+ "location": "#/0",
318
+ "keyword": "title",
319
+ "expected": ["Unevaluated"]
320
+ },
321
+ {
322
+ "location": "#/1",
323
+ "keyword": "title",
324
+ "expected": ["Unevaluated"]
325
+ }
326
+ ]
327
+ }
328
+ ]
329
+ },
330
+ {
331
+ "title": "`unevaluatedItems` with `prefixItems`",
332
+ "schema": {
333
+ "prefixItems": [{ "title": "Evaluated" }],
334
+ "unevaluatedItems": { "title": "Unevaluated" }
335
+ },
336
+ "subjects": [
337
+ {
338
+ "instance": [42, 24],
339
+ "assertions": [
340
+ {
341
+ "location": "#/0",
342
+ "keyword": "title",
343
+ "expected": ["Evaluated"]
344
+ },
345
+ {
346
+ "location": "#/1",
347
+ "keyword": "title",
348
+ "expected": ["Unevaluated"]
349
+ }
350
+ ]
351
+ }
352
+ ]
353
+ },
354
+ {
355
+ "title": "`unevaluatedItems` with `contains`",
356
+ "schema": {
357
+ "contains": {
358
+ "type": "string",
359
+ "title": "Evaluated"
360
+ },
361
+ "unevaluatedItems": { "title": "Unevaluated" }
362
+ },
363
+ "subjects": [
364
+ {
365
+ "instance": ["foo", 42],
366
+ "assertions": [
367
+ {
368
+ "location": "#/0",
369
+ "keyword": "title",
370
+ "expected": ["Evaluated"]
371
+ },
372
+ {
373
+ "location": "#/1",
374
+ "keyword": "title",
375
+ "expected": ["Unevaluated"]
376
+ }
377
+ ]
378
+ }
379
+ ]
380
+ },
381
+ {
382
+ "title": "`unevaluatedItems` with `if`, `then`, and `else`",
383
+ "schema": {
384
+ "if": {
385
+ "prefixItems": [
386
+ {
387
+ "type": "string",
388
+ "title": "If"
389
+ }
390
+ ]
391
+ },
392
+ "then": {
393
+ "prefixItems": [
394
+ { "title": "Then" }
395
+ ]
396
+ },
397
+ "else": {
398
+ "prefixItems": [
399
+ { "title": "Else" }
400
+ ]
401
+ },
402
+ "unevaluatedItems": { "title": "Unevaluated" }
403
+ },
404
+ "subjects": [
405
+ {
406
+ "instance": ["", 42],
407
+ "assertions": [
408
+ {
409
+ "location": "#/0",
410
+ "keyword": "title",
411
+ "expected": ["Then", "If"]
412
+ },
413
+ {
414
+ "location": "#/1",
415
+ "keyword": "title",
416
+ "expected": ["Unevaluated"]
417
+ }
418
+ ]
419
+ },
420
+ {
421
+ "instance": [42, ""],
422
+ "assertions": [
423
+ {
424
+ "location": "#/0",
425
+ "keyword": "title",
426
+ "expected": ["Else"]
427
+ },
428
+ {
429
+ "location": "#/1",
430
+ "keyword": "title",
431
+ "expected": ["Unevaluated"]
432
+ }
433
+ ]
434
+ }
435
+ ]
436
+ },
437
+ {
438
+ "title": "`unevaluatedItems` with `allOf`",
439
+ "schema": {
440
+ "allOf": [
441
+ {
442
+ "prefixItems": [
443
+ { "title": "Evaluated" }
444
+ ]
445
+ }
446
+ ],
447
+ "unevaluatedItems": { "title": "Unevaluated" }
448
+ },
449
+ "subjects": [
450
+ {
451
+ "instance": [42, 24],
452
+ "assertions": [
453
+ {
454
+ "location": "#/0",
455
+ "keyword": "title",
456
+ "expected": ["Evaluated"]
457
+ },
458
+ {
459
+ "location": "#/1",
460
+ "keyword": "title",
461
+ "expected": ["Unevaluated"]
462
+ }
463
+ ]
464
+ }
465
+ ]
466
+ },
467
+ {
468
+ "title": "`unevaluatedItems` with `anyOf`",
469
+ "schema": {
470
+ "anyOf": [
471
+ {
472
+ "prefixItems": [
473
+ { "title": "Evaluated" }
474
+ ]
475
+ }
476
+ ],
477
+ "unevaluatedItems": { "title": "Unevaluated" }
478
+ },
479
+ "subjects": [
480
+ {
481
+ "instance": [42, 24],
482
+ "assertions": [
483
+ {
484
+ "location": "#/0",
485
+ "keyword": "title",
486
+ "expected": ["Evaluated"]
487
+ },
488
+ {
489
+ "location": "#/1",
490
+ "keyword": "title",
491
+ "expected": ["Unevaluated"]
492
+ }
493
+ ]
494
+ }
495
+ ]
496
+ },
497
+ {
498
+ "title": "`unevaluatedItems` with `oneOf`",
499
+ "schema": {
500
+ "oneOf": [
501
+ {
502
+ "prefixItems": [
503
+ { "title": "Evaluated" }
504
+ ]
505
+ }
506
+ ],
507
+ "unevaluatedItems": { "title": "Unevaluated" }
508
+ },
509
+ "subjects": [
510
+ {
511
+ "instance": [42, 24],
512
+ "assertions": [
513
+ {
514
+ "location": "#/0",
515
+ "keyword": "title",
516
+ "expected": ["Evaluated"]
517
+ },
518
+ {
519
+ "location": "#/1",
520
+ "keyword": "title",
521
+ "expected": ["Unevaluated"]
522
+ }
523
+ ]
524
+ }
525
+ ]
526
+ },
527
+ {
528
+ "title": "`unevaluatedItems` with `not`",
529
+ "schema": {
530
+ "not": {
531
+ "not": {
532
+ "prefixItems": [
533
+ { "title": "Evaluated" }
534
+ ]
535
+ }
536
+ },
537
+ "unevaluatedItems": { "title": "Unevaluated" }
538
+ },
539
+ "subjects": [
540
+ {
541
+ "instance": [42, 24],
542
+ "assertions": [
543
+ {
544
+ "location": "#/0",
545
+ "keyword": "title",
546
+ "expected": ["Unevaluated"]
547
+ },
548
+ {
549
+ "location": "#/1",
550
+ "keyword": "title",
551
+ "expected": ["Unevaluated"]
552
+ }
553
+ ]
554
+ }
555
+ ]
556
+ }
557
+ ]
@@ -0,0 +1,91 @@
1
+ [
2
+ {
3
+ "title": "Unknown keywords are not annotations in draft-04",
4
+ "schema": {
5
+ "$schema": "http://json-schema.org/draft-04/schema#",
6
+ "unknown": "Foo"
7
+ },
8
+ "subjects": [
9
+ {
10
+ "title": "Any instance",
11
+ "instance": 42,
12
+ "assertions": [
13
+ {
14
+ "location": "#",
15
+ "keyword": "unknown",
16
+ "expected": []
17
+ }
18
+ ]
19
+ }
20
+ ]
21
+ },
22
+ {
23
+ "title": "Unknown keywords are not annotations in draft-06",
24
+ "schema": {
25
+ "$schema": "http://json-schema.org/draft-06/schema#",
26
+ "unknown": "Foo"
27
+ },
28
+ "subjects": [
29
+ {
30
+ "title": "Any instance",
31
+ "instance": 42,
32
+ "assertions": [
33
+ {
34
+ "location": "#",
35
+ "keyword": "unknown",
36
+ "expected": []
37
+ }
38
+ ]
39
+ }
40
+ ]
41
+ },
42
+ {
43
+ "title": "Unknown keywords are not annotations in draft-07",
44
+ "schema": {
45
+ "$schema": "http://json-schema.org/draft-07/schema#",
46
+ "unknown": "Foo"
47
+ },
48
+ "subjects": [
49
+ {
50
+ "title": "Any instance",
51
+ "instance": 42,
52
+ "assertions": [
53
+ {
54
+ "location": "#",
55
+ "keyword": "unknown",
56
+ "expected": []
57
+ }
58
+ ]
59
+ }
60
+ ]
61
+ },
62
+ {
63
+ "title": "Unknown keywords may or may not be annotations in 2019-09",
64
+ "schema": {
65
+ "$schema": "https://json-schema.org/draft/2019-09/schema",
66
+ "unknown": "Foo"
67
+ },
68
+ "$comment": "'subjects' is intentionally left empty",
69
+ "subjects": []
70
+ },
71
+ {
72
+ "title": "Unknown keywords are annotations in 2020-12",
73
+ "schema": {
74
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
75
+ "unknown": "Foo"
76
+ },
77
+ "subjects": [
78
+ {
79
+ "title": "Any instance",
80
+ "instance": 42,
81
+ "assertions": [
82
+ {
83
+ "location": "#",
84
+ "keyword": "unknown",
85
+ "expected": ["Foo"]
86
+ }
87
+ ]
88
+ }
89
+ ]
90
+ }
91
+ ]