@@ -19,6 +19,12 @@ use Helper;
19
19
# spec version -> vocab classes
20
20
my %vocabularies = unpairs(JSON::Schema::Modern-> new-> __all_metaschema_vocabulary_classes);
21
21
22
+ my %configs = (
23
+ specification_version => ' draft2020-12' ,
24
+ vocabularies => $vocabularies {' draft2020-12' },
25
+ configs => {},
26
+ );
27
+
22
28
subtest ' boolean document' => sub {
23
29
cmp_deeply(
24
30
JSON::Schema::Modern::Document-> new(schema => false),
@@ -27,9 +33,7 @@ subtest 'boolean document' => sub {
27
33
' ' => {
28
34
path => ' ' ,
29
35
canonical_uri => str(' ' ),
30
- specification_version => ' draft2020-12' ,
31
- vocabularies => ignore, # there are no keywords, so vocabularies doesn't matter
32
- configs => {},
36
+ %configs ,
33
37
},
34
38
],
35
39
canonical_uri => [ str(' ' ) ],
@@ -59,9 +63,7 @@ subtest 'boolean document' => sub {
59
63
' https://foo.com' => {
60
64
path => ' ' ,
61
65
canonical_uri => str(' https://foo.com' ),
62
- specification_version => ' draft2020-12' ,
63
- vocabularies => ignore, # there are no keywords, so vocabularies doesn't matter
64
- configs => {},
66
+ %configs ,
65
67
},
66
68
],
67
69
canonical_uri => [ str(' https://foo.com' ) ],
@@ -82,9 +84,7 @@ subtest 'object document' => sub {
82
84
str($_ //' ' ) => {
83
85
path => ' ' ,
84
86
canonical_uri => str($_ //' ' ),
85
- specification_version => ' draft2020-12' ,
86
- vocabularies => $vocabularies {' draft2020-12' },
87
- configs => {},
87
+ %configs ,
88
88
},
89
89
],
90
90
canonical_uri => [ str($_ //' ' ) ],
@@ -105,9 +105,7 @@ subtest 'object document' => sub {
105
105
' https://foo.com' => {
106
106
path => ' ' ,
107
107
canonical_uri => str(' https://foo.com' ),
108
- specification_version => ' draft2020-12' ,
109
- vocabularies => $vocabularies {' draft2020-12' },
110
- configs => {},
108
+ %configs ,
111
109
},
112
110
],
113
111
canonical_uri => [ str(' https://foo.com' ) ],
@@ -127,9 +125,7 @@ subtest 'object document' => sub {
127
125
' https://foo.com' => {
128
126
path => ' ' ,
129
127
canonical_uri => str(' https://foo.com' ),
130
- specification_version => ' draft2020-12' ,
131
- vocabularies => $vocabularies {' draft2020-12' },
132
- configs => {},
128
+ %configs ,
133
129
},
134
130
],
135
131
canonical_uri => [ str(' https://foo.com' ) ], # note canonical_uri has been overwritten
@@ -150,9 +146,7 @@ subtest 'object document' => sub {
150
146
' https://bar.com' => {
151
147
path => ' ' ,
152
148
canonical_uri => str(' https://bar.com' ),
153
- specification_version => ' draft2020-12' ,
154
- vocabularies => $vocabularies {' draft2020-12' },
155
- configs => {},
149
+ %configs ,
156
150
},
157
151
],
158
152
canonical_uri => [ str(' https://bar.com' ) ], # note canonical_uri has been overwritten
@@ -174,9 +168,7 @@ subtest 'object document' => sub {
174
168
' https://example.com' => {
175
169
path => ' ' ,
176
170
canonical_uri => str(' https://example.com' ),
177
- specification_version => ' draft2020-12' ,
178
- vocabularies => $vocabularies {' draft2020-12' },
179
- configs => {},
171
+ %configs ,
180
172
},
181
173
],
182
174
),
@@ -193,9 +185,7 @@ subtest 'object document' => sub {
193
185
' https://foo.com' => {
194
186
path => ' ' ,
195
187
canonical_uri => str(' https://foo.com' ),
196
- specification_version => ' draft2020-12' ,
197
- vocabularies => $vocabularies {' draft2020-12' },
198
- configs => {},
188
+ %configs ,
199
189
},
200
190
],
201
191
canonical_uri => [ str(' https://foo.com' ) ],
@@ -220,9 +210,7 @@ subtest 'object document' => sub {
220
210
' https://bar.com' => {
221
211
path => ' ' ,
222
212
canonical_uri => str(' https://bar.com' ),
223
- specification_version => ' draft2020-12' ,
224
- vocabularies => $vocabularies {' draft2020-12' },
225
- configs => {},
213
+ %configs ,
226
214
anchors => {
227
215
my_anchor => {
228
216
path => ' /allOf/0' ,
@@ -233,9 +221,7 @@ subtest 'object document' => sub {
233
221
' https://bar.com/x/y/z.json' => {
234
222
path => ' /allOf/1' ,
235
223
canonical_uri => str(' https://bar.com/x/y/z.json' ),
236
- specification_version => ' draft2020-12' ,
237
- vocabularies => $vocabularies {' draft2020-12' },
238
- configs => {},
224
+ %configs ,
239
225
},
240
226
),
241
227
canonical_uri => [ str(' https://bar.com' ) ],
@@ -256,9 +242,7 @@ subtest 'object document' => sub {
256
242
' https://my-base.com/relative' => {
257
243
path => ' ' ,
258
244
canonical_uri => str(' https://my-base.com/relative' ),
259
- specification_version => ' draft2020-12' ,
260
- vocabularies => $vocabularies {' draft2020-12' },
261
- configs => {},
245
+ %configs ,
262
246
},
263
247
],
264
248
canonical_uri => [ str(' https://my-base.com/relative' ) ],
@@ -282,16 +266,13 @@ subtest 'object document' => sub {
282
266
listmethods(
283
267
resource_index => unordered_pairs(
284
268
' ' => {
285
- path => ' ' , canonical_uri => str(' ' ), specification_version => ' draft2020-12' ,
286
- vocabularies => $vocabularies {' draft2020-12' },
287
- configs => {},
269
+ path => ' ' , canonical_uri => str(' ' ),
270
+ %configs ,
288
271
},
289
272
' my_foo' => {
290
273
path => ' /$defs/foo' ,
291
274
canonical_uri => str(' my_foo' ),
292
- specification_version => ' draft2020-12' ,
293
- vocabularies => $vocabularies {' draft2020-12' },
294
- configs => {},
275
+ %configs ,
295
276
},
296
277
),
297
278
_entities => [ { map +($_ => 0), ' ' , ' /$defs/foo' } ],
@@ -313,16 +294,13 @@ subtest 'object document' => sub {
313
294
listmethods(
314
295
resource_index => unordered_pairs(
315
296
' ' => {
316
- path => ' ' , canonical_uri => str(' ' ), specification_version => ' draft2020-12' ,
317
- vocabularies => $vocabularies {' draft2020-12' },
318
- configs => {},
297
+ path => ' ' , canonical_uri => str(' ' ),
298
+ %configs ,
319
299
},
320
300
' http://localhost:4242/my_foo' => {
321
301
path => ' /$defs/foo' ,
322
302
canonical_uri => str(' http://localhost:4242/my_foo' ),
323
- specification_version => ' draft2020-12' ,
324
- vocabularies => $vocabularies {' draft2020-12' },
325
- configs => {},
303
+ %configs ,
326
304
},
327
305
),
328
306
_entities => [ { map +($_ => 0), ' ' , ' /$defs/foo' } ],
@@ -339,9 +317,9 @@ subtest 'object document' => sub {
339
317
listmethods(
340
318
resource_index => [
341
319
' ' => {
342
- path => ' ' , canonical_uri => str( ' ' ), specification_version => ' draft2020-12 ' ,
343
- vocabularies => $vocabularies { ' draft2020-12 ' } ,
344
- configs => {} ,
320
+ path => ' ' ,
321
+ canonical_uri => str( ' ' ) ,
322
+ % configs ,
345
323
anchors => {
346
324
my_anchor => {
347
325
path => ' ' ,
@@ -366,9 +344,7 @@ subtest 'object document' => sub {
366
344
' https://example.com' => {
367
345
path => ' ' ,
368
346
canonical_uri => str(' https://example.com' ),
369
- specification_version => ' draft2020-12' ,
370
- vocabularies => $vocabularies {' draft2020-12' },
371
- configs => {},
347
+ %configs ,
372
348
anchors => {
373
349
my_anchor => {
374
350
path => ' ' ,
@@ -393,9 +369,7 @@ subtest 'object document' => sub {
393
369
' https://my-base.com' => {
394
370
path => ' ' ,
395
371
canonical_uri => str(' https://my-base.com' ),
396
- specification_version => ' draft2020-12' ,
397
- vocabularies => $vocabularies {' draft2020-12' },
398
- configs => {},
372
+ %configs ,
399
373
anchors => {
400
374
my_anchor => {
401
375
path => ' ' ,
@@ -424,9 +398,7 @@ subtest 'object document' => sub {
424
398
' https://my-base.com' => {
425
399
path => ' ' ,
426
400
canonical_uri => str(' https://my-base.com' ),
427
- specification_version => ' draft2020-12' ,
428
- vocabularies => $vocabularies {' draft2020-12' },
429
- configs => {},
401
+ %configs ,
430
402
anchors => {
431
403
my_anchor => {
432
404
path => ' /$defs/foo' ,
@@ -454,9 +426,9 @@ subtest '$id and $anchor as properties' => sub {
454
426
listmethods(
455
427
resource_index => [
456
428
' ' => {
457
- path => ' ' , canonical_uri => str( ' ' ), specification_version => ' draft2020-12 ' ,
458
- vocabularies => $vocabularies { ' draft2020-12 ' } ,
459
- configs => {} ,
429
+ path => ' ' ,
430
+ canonical_uri => str( ' ' ) ,
431
+ % configs ,
460
432
},
461
433
],
462
434
_entities => [ { map +($_ => 0), ' ' , ' /properties/$id' , ' /properties/$anchor' } ],
@@ -487,9 +459,7 @@ subtest '$id with an empty fragment' => sub {
487
459
' http://localhost:4242/my_foo' => {
488
460
path => ' /$defs/foo' ,
489
461
canonical_uri => str(' http://localhost:4242/my_foo' ),
490
- specification_version => ' draft2020-12' ,
491
- vocabularies => $vocabularies {' draft2020-12' },
492
- configs => {},
462
+ %configs ,
493
463
},
494
464
),
495
465
_entities => [ { map +($_ => 0), ' ' , ' /$defs/foo' } ],
@@ -668,9 +638,7 @@ subtest '$anchor and $id below an $id that is not at the document root' => sub {
668
638
},
669
639
' https://bar.com' => {
670
640
path => ' /allOf/0' , canonical_uri => str(' https://bar.com' ),
671
- specification_version => ' draft2020-12' ,
672
- vocabularies => $vocabularies {' draft2020-12' },
673
- configs => {},
641
+ %configs ,
674
642
anchors => {
675
643
my_anchor => {
676
644
path => ' /allOf/0' ,
@@ -684,9 +652,7 @@ subtest '$anchor and $id below an $id that is not at the document root' => sub {
684
652
},
685
653
' https://bar.com/inner_id' => {
686
654
path => ' /allOf/0/not/not' , canonical_uri => str(' https://bar.com/inner_id' ),
687
- specification_version => ' draft2020-12' ,
688
- vocabularies => $vocabularies {' draft2020-12' },
689
- configs => {},
655
+ %configs ,
690
656
},
691
657
),
692
658
_entities => [ { map +($_ => 0), ' ' , ' /allOf/0' , ' /allOf/0/not' , ' /allOf/0/not/not' } ],
@@ -741,9 +707,7 @@ subtest 'JSON pointer and URI escaping' => sub {
741
707
' http://localhost:4242/~username' => {
742
708
path => ' /$defs/foo/patternProperties/~0' ,
743
709
canonical_uri => str(' http://localhost:4242/~username' ),
744
- specification_version => ' draft2020-12' ,
745
- vocabularies => $vocabularies {' draft2020-12' },
746
- configs => {},
710
+ %configs ,
747
711
anchors => {
748
712
tilde => {
749
713
path => ' /$defs/foo/patternProperties/~0/properties/~0~1' ,
@@ -754,9 +718,7 @@ subtest 'JSON pointer and URI escaping' => sub {
754
718
' http://localhost:4242/my_slash' => {
755
719
path => ' /$defs/foo/patternProperties/~1' ,
756
720
canonical_uri => str(' http://localhost:4242/my_slash' ),
757
- specification_version => ' draft2020-12' ,
758
- vocabularies => $vocabularies {' draft2020-12' },
759
- configs => {},
721
+ %configs ,
760
722
anchors => {
761
723
slash => {
762
724
path => ' /$defs/foo/patternProperties/~1/properties/~0~1' ,
@@ -767,9 +729,7 @@ subtest 'JSON pointer and URI escaping' => sub {
767
729
' http://localhost:4242/~username/my_slash' => {
768
730
path => ' /$defs/foo/patternProperties/[~0~1]' ,
769
731
canonical_uri => str(' http://localhost:4242/~username/my_slash' ),
770
- specification_version => ' draft2020-12' ,
771
- vocabularies => $vocabularies {' draft2020-12' },
772
- configs => {},
732
+ %configs ,
773
733
anchors => {
774
734
tildeslash => {
775
735
path => ' /$defs/foo/patternProperties/[~0~1]/properties/~0~1' ,
@@ -923,9 +883,7 @@ subtest 'create document with explicit canonical_uri set to the same as root $id
923
883
' https://foo.com/x/y/z' => {
924
884
path => ' ' ,
925
885
canonical_uri => str(' https://foo.com/x/y/z' ),
926
- specification_version => ' draft2020-12' ,
927
- vocabularies => $vocabularies {' draft2020-12' },
928
- configs => {},
886
+ %configs ,
929
887
},
930
888
],
931
889
canonical_uri => [ str(' https://foo.com/x/y/z' ) ],
0 commit comments