shinkansen-transmission 2.1.15 → 2.2.2

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 (82) hide show
  1. package/.husky/pre-commit +4 -0
  2. package/babel.config.js +1 -1
  3. package/index.js +6 -1
  4. package/lib/index.js +1 -1
  5. package/lib/transmission/common/index.js +1 -1
  6. package/lib/transmission/from-document-to-hash/index.js +1 -1
  7. package/lib/transmission/from-hash-to-document/index.js +1 -1
  8. package/lib/transmission/index.js +1 -1
  9. package/lib/transmission/to-zashiki/index.js +1 -1
  10. package/lib/transmission/to-zashiki/transform-root-schema.js +1 -1
  11. package/lib/transmission/to-zashiki/transform-schema.js +1 -1
  12. package/package.json +23 -30
  13. package/src/transmission/from-document-to-hash/index.js +75 -29
  14. package/src/transmission/from-hash-to-document/index.js +13 -10
  15. package/src/transmission/to-zashiki/transform-root-schema.js +143 -136
  16. package/src/transmission/to-zashiki/transform-schema.js +3256 -1952
  17. package/.github/dependabot.yml +0 -9
  18. package/test/transmission/common/index.spec.js +0 -1348
  19. package/test/transmission/from-document-to-hash/index.spec.js +0 -1866
  20. package/test/transmission/from-hash-to-document/index.spec.js +0 -1523
  21. package/test/transmission/to-zashiki/transform-root-schema/transforming-array-type-schemas.spec.js +0 -1784
  22. package/test/transmission/to-zashiki/transform-root-schema/transforming-boolean-type-schemas.spec.js +0 -334
  23. package/test/transmission/to-zashiki/transform-root-schema/transforming-null-type-schemas.spec.js +0 -253
  24. package/test/transmission/to-zashiki/transform-root-schema/transforming-number-type-schemas.spec.js +0 -565
  25. package/test/transmission/to-zashiki/transform-root-schema/transforming-object-type-schemas.spec.js +0 -1715
  26. package/test/transmission/to-zashiki/transform-root-schema/transforming-string-type-schemas.spec.js +0 -496
  27. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-array-type-schemas.spec.js +0 -31633
  28. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-boolean-type-schemas.spec.js +0 -359
  29. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-null-type-schemas.spec.js +0 -359
  30. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-number-type-schemas.spec.js +0 -446
  31. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-object-type-schemas.spec.js +0 -8348
  32. package/test/transmission/to-zashiki/transform-root-schema/with-values/with-params/transforming-string-type-schemas.spec.js +0 -446
  33. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-array-type-schemas.spec.js +0 -30373
  34. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-boolean-type-schemas.spec.js +0 -334
  35. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-null-type-schemas.spec.js +0 -253
  36. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-number-type-schemas.spec.js +0 -421
  37. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-object-type-schemas.spec.js +0 -7826
  38. package/test/transmission/to-zashiki/transform-root-schema/with-values/without-params/transforming-string-type-schemas.spec.js +0 -421
  39. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-array-type-schemas.spec.js +0 -31111
  40. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-boolean-type-schemas.spec.js +0 -347
  41. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-null-type-schemas.spec.js +0 -344
  42. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-number-type-schemas.spec.js +0 -434
  43. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-object-type-schemas.spec.js +0 -8222
  44. package/test/transmission/to-zashiki/transform-root-schema/without-values/with-params/transforming-string-type-schemas.spec.js +0 -434
  45. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-array-type-schemas.spec.js +0 -29494
  46. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-boolean-type-schemas.spec.js +0 -312
  47. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-null-type-schemas.spec.js +0 -309
  48. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-number-type-schemas.spec.js +0 -399
  49. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-object-type-schemas.spec.js +0 -7584
  50. package/test/transmission/to-zashiki/transform-root-schema/without-values/without-params/transforming-string-type-schemas.spec.js +0 -398
  51. package/test/transmission/to-zashiki/transform-root-schema.spec.js +0 -22
  52. package/test/transmission/to-zashiki/transform-schema/transforming-array-type-schemas.spec.js +0 -1806
  53. package/test/transmission/to-zashiki/transform-schema/transforming-boolean-type-schemas.spec.js +0 -340
  54. package/test/transmission/to-zashiki/transform-schema/transforming-null-type-schemas.spec.js +0 -259
  55. package/test/transmission/to-zashiki/transform-schema/transforming-number-type-schemas.spec.js +0 -571
  56. package/test/transmission/to-zashiki/transform-schema/transforming-object-type-schemas.spec.js +0 -1737
  57. package/test/transmission/to-zashiki/transform-schema/transforming-string-type-schemas.spec.js +0 -502
  58. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-array-type-schemas.spec.js +0 -32173
  59. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-boolean-type-schemas.spec.js +0 -377
  60. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-null-type-schemas.spec.js +0 -377
  61. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-number-type-schemas.spec.js +0 -464
  62. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-object-type-schemas.spec.js +0 -8525
  63. package/test/transmission/to-zashiki/transform-schema/with-values/with-params/transforming-string-type-schemas.spec.js +0 -464
  64. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-array-type-schemas.spec.js +0 -30910
  65. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-boolean-type-schemas.spec.js +0 -352
  66. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-null-type-schemas.spec.js +0 -271
  67. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-number-type-schemas.spec.js +0 -439
  68. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-object-type-schemas.spec.js +0 -8003
  69. package/test/transmission/to-zashiki/transform-schema/with-values/without-params/transforming-string-type-schemas.spec.js +0 -439
  70. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-array-type-schemas.spec.js +0 -31654
  71. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-boolean-type-schemas.spec.js +0 -365
  72. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-null-type-schemas.spec.js +0 -362
  73. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-number-type-schemas.spec.js +0 -452
  74. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-object-type-schemas.spec.js +0 -8399
  75. package/test/transmission/to-zashiki/transform-schema/without-values/with-params/transforming-string-type-schemas.spec.js +0 -452
  76. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-array-type-schemas.spec.js +0 -29671
  77. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-boolean-type-schemas.spec.js +0 -320
  78. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-null-type-schemas.spec.js +0 -317
  79. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-number-type-schemas.spec.js +0 -407
  80. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-object-type-schemas.spec.js +0 -7645
  81. package/test/transmission/to-zashiki/transform-schema/without-values/without-params/transforming-string-type-schemas.spec.js +0 -406
  82. package/test/transmission/to-zashiki/transform-schema.spec.js +0 -777
@@ -1,1806 +0,0 @@
1
- import debug from 'debug'
2
-
3
- import { expect } from 'chai'
4
-
5
- import transform from 'shinkansen-transmission/transmission/to-zashiki/transform-schema'
6
-
7
- describe('shinkansen-transmission/transmission/to-zashiki/transform-schema', () => {
8
- before(() => {
9
- const {
10
- env: {
11
- DEBUG
12
- }
13
- } = process
14
-
15
- if (DEBUG) debug.enable(DEBUG)
16
- })
17
-
18
- /*
19
- * Array
20
- */
21
- describe('Transforming `array` type schemas', () => {
22
- it('transforms', () => {
23
- const schema = { type: 'array' }
24
-
25
- expect(transform(schema))
26
- .to.eql({
27
- meta: {
28
- type: 'array',
29
- uri: '#/',
30
- rootSchema: {},
31
- schema
32
- },
33
- elements: {
34
- fields: []
35
- }
36
- })
37
- })
38
-
39
- it('transforms with `enum`', () => {
40
- const schema = {
41
- type: 'array',
42
- enum: [
43
- [],
44
- [],
45
- []
46
- ],
47
- minItems: 1,
48
- maxItems: 9,
49
- uniqueItems: true,
50
- minContains: 1,
51
- maxContains: 9
52
- }
53
-
54
- expect(transform(schema))
55
- .to.eql({
56
- meta: {
57
- type: 'array',
58
- uri: '#/',
59
- rootSchema: {},
60
- schema,
61
- minItems: 1,
62
- maxItems: 9,
63
- hasUniqueItems: true,
64
- minContains: 1,
65
- maxContains: 9,
66
- items: [
67
- [],
68
- [],
69
- []
70
- ],
71
- selectedItems: []
72
- },
73
- elements: {
74
- enum: {
75
- id: '#/',
76
- minItems: 1,
77
- maxItems: 9,
78
- hasUniqueItems: true,
79
- minContains: 1,
80
- maxContains: 9,
81
- items: [
82
- [],
83
- [],
84
- []
85
- ],
86
- selectedItems: []
87
- }
88
- }
89
- })
90
- })
91
-
92
- it('transforms with `anyOf`', () => {
93
- const schema = {
94
- type: 'array',
95
- anyOf: [
96
- { const: [] },
97
- { const: [] },
98
- { const: [] }
99
- ]
100
- }
101
-
102
- expect(transform(schema))
103
- .to.eql({
104
- meta: {
105
- type: 'array',
106
- uri: '#/',
107
- rootSchema: {},
108
- schema,
109
- items: [
110
- {
111
- meta: {
112
- type: 'array',
113
- item: 0,
114
- parentUri: '#/',
115
- uri: '#/0',
116
- rootSchema: {},
117
- schema: {
118
- const: []
119
- }
120
- },
121
- elements: {
122
- fields: []
123
- }
124
- },
125
- {
126
- meta: {
127
- type: 'array',
128
- item: 1,
129
- parentUri: '#/',
130
- uri: '#/1',
131
- rootSchema: {},
132
- schema: {
133
- const: []
134
- }
135
- },
136
- elements: {
137
- fields: []
138
- }
139
- },
140
- {
141
- meta: {
142
- type: 'array',
143
- item: 2,
144
- parentUri: '#/',
145
- uri: '#/2',
146
- rootSchema: {},
147
- schema: {
148
- const: []
149
- }
150
- },
151
- elements: {
152
- fields: []
153
- }
154
- }
155
- ],
156
- selectedItems: []
157
- },
158
- elements: {
159
- anyOf: {
160
- id: '#/',
161
- items: [
162
- {
163
- meta: {
164
- type: 'array',
165
- item: 0,
166
- parentUri: '#/',
167
- uri: '#/0',
168
- rootSchema: {},
169
- schema: {
170
- const: []
171
- }
172
- },
173
- elements: {
174
- fields: []
175
- }
176
- },
177
- {
178
- meta: {
179
- type: 'array',
180
- item: 1,
181
- parentUri: '#/',
182
- uri: '#/1',
183
- rootSchema: {},
184
- schema: {
185
- const: []
186
- }
187
- },
188
- elements: {
189
- fields: []
190
- }
191
- },
192
- {
193
- meta: {
194
- type: 'array',
195
- item: 2,
196
- parentUri: '#/',
197
- uri: '#/2',
198
- rootSchema: {},
199
- schema: {
200
- const: []
201
- }
202
- },
203
- elements: {
204
- fields: []
205
- }
206
- }
207
- ],
208
- selectedItems: []
209
- }
210
- }
211
- })
212
- })
213
-
214
- it('transforms with `oneOf`', () => {
215
- const schema = {
216
- type: 'array',
217
- oneOf: [
218
- {
219
- const: [],
220
- minItems: 1,
221
- maxItems: 9,
222
- uniqueItems: true,
223
- minContains: 1,
224
- maxContains: 9
225
- },
226
- {
227
- const: [],
228
- minItems: 1,
229
- maxItems: 9,
230
- uniqueItems: true,
231
- minContains: 1,
232
- maxContains: 9
233
- },
234
- {
235
- const: [],
236
- minItems: 1,
237
- maxItems: 9,
238
- uniqueItems: true,
239
- minContains: 1,
240
- maxContains: 9
241
- }
242
- ]
243
- }
244
-
245
- expect(transform(schema))
246
- .to.eql({
247
- meta: {
248
- type: 'array',
249
- uri: '#/',
250
- rootSchema: {},
251
- schema,
252
- items: [
253
- {
254
- meta: {
255
- type: 'array',
256
- item: 0,
257
- parentUri: '#/',
258
- uri: '#/0',
259
- rootSchema: {},
260
- schema: {
261
- const: [],
262
- minItems: 1,
263
- maxItems: 9,
264
- uniqueItems: true,
265
- minContains: 1,
266
- maxContains: 9
267
- },
268
- minItems: 1,
269
- maxItems: 9,
270
- hasUniqueItems: true,
271
- minContains: 1,
272
- maxContains: 9
273
- },
274
- elements: {
275
- fields: []
276
- }
277
- },
278
- {
279
- meta: {
280
- type: 'array',
281
- item: 1,
282
- parentUri: '#/',
283
- uri: '#/1',
284
- rootSchema: {},
285
- schema: {
286
- const: [],
287
- minItems: 1,
288
- maxItems: 9,
289
- uniqueItems: true,
290
- minContains: 1,
291
- maxContains: 9
292
- },
293
- minItems: 1,
294
- maxItems: 9,
295
- hasUniqueItems: true,
296
- minContains: 1,
297
- maxContains: 9
298
- },
299
- elements: {
300
- fields: []
301
- }
302
- },
303
- {
304
- meta: {
305
- type: 'array',
306
- item: 2,
307
- parentUri: '#/',
308
- uri: '#/2',
309
- rootSchema: {},
310
- schema: {
311
- const: [],
312
- minItems: 1,
313
- maxItems: 9,
314
- uniqueItems: true,
315
- minContains: 1,
316
- maxContains: 9
317
- },
318
- minItems: 1,
319
- maxItems: 9,
320
- hasUniqueItems: true,
321
- minContains: 1,
322
- maxContains: 9
323
- },
324
- elements: {
325
- fields: []
326
- }
327
- }
328
- ],
329
- selectedItems: []
330
- },
331
- elements: {
332
- oneOf: {
333
- id: '#/',
334
- items: [
335
- {
336
- meta: {
337
- type: 'array',
338
- item: 0,
339
- parentUri: '#/',
340
- uri: '#/0',
341
- rootSchema: {},
342
- schema: {
343
- const: [],
344
- minItems: 1,
345
- maxItems: 9,
346
- uniqueItems: true,
347
- minContains: 1,
348
- maxContains: 9
349
- },
350
- minItems: 1,
351
- maxItems: 9,
352
- hasUniqueItems: true,
353
- minContains: 1,
354
- maxContains: 9
355
- },
356
- elements: {
357
- fields: []
358
- }
359
- },
360
- {
361
- meta: {
362
- type: 'array',
363
- item: 1,
364
- parentUri: '#/',
365
- uri: '#/1',
366
- rootSchema: {},
367
- schema: {
368
- const: [],
369
- minItems: 1,
370
- maxItems: 9,
371
- uniqueItems: true,
372
- minContains: 1,
373
- maxContains: 9
374
- },
375
- minItems: 1,
376
- maxItems: 9,
377
- hasUniqueItems: true,
378
- minContains: 1,
379
- maxContains: 9
380
- },
381
- elements: {
382
- fields: []
383
- }
384
- },
385
- {
386
- meta: {
387
- type: 'array',
388
- item: 2,
389
- parentUri: '#/',
390
- uri: '#/2',
391
- rootSchema: {},
392
- schema: {
393
- const: [],
394
- minItems: 1,
395
- maxItems: 9,
396
- uniqueItems: true,
397
- minContains: 1,
398
- maxContains: 9
399
- },
400
- minItems: 1,
401
- maxItems: 9,
402
- hasUniqueItems: true,
403
- minContains: 1,
404
- maxContains: 9
405
- },
406
- elements: {
407
- fields: []
408
- }
409
- }
410
- ],
411
- selectedItems: []
412
- }
413
- }
414
- })
415
- })
416
-
417
- it('transforms with `allOf`', () => {
418
- const schema = {
419
- type: 'array',
420
- allOf: [
421
- { const: [] },
422
- { minItems: 1 },
423
- { maxItems: 9 },
424
- { uniqueItems: true },
425
- { minContains: 1 },
426
- { maxContains: 9 }
427
- ]
428
- }
429
-
430
- expect(transform(schema))
431
- .to.eql({
432
- meta: {
433
- type: 'array',
434
- uri: '#/',
435
- rootSchema: {},
436
- schema,
437
- minItems: 1,
438
- maxItems: 9,
439
- hasUniqueItems: true,
440
- minContains: 1,
441
- maxContains: 9
442
- },
443
- elements: {
444
- field: {
445
- id: '#/',
446
- minItems: 1,
447
- maxItems: 9,
448
- hasUniqueItems: true,
449
- minContains: 1,
450
- maxContains: 9
451
- }
452
- }
453
- })
454
- })
455
-
456
- it('transforms without `enum` or `anyOf` or `oneOf` or `allOf`', () => {
457
- const schema = {
458
- type: 'array',
459
- const: [],
460
- minItems: 1,
461
- maxItems: 9,
462
- uniqueItems: true,
463
- minContains: 1,
464
- maxContains: 9
465
- }
466
-
467
- expect(transform(schema))
468
- .to.eql({
469
- meta: {
470
- type: 'array',
471
- uri: '#/',
472
- rootSchema: {},
473
- schema,
474
- minItems: 1,
475
- maxItems: 9,
476
- hasUniqueItems: true,
477
- minContains: 1,
478
- maxContains: 9
479
- },
480
- elements: {
481
- fields: []
482
- }
483
- })
484
- })
485
-
486
- it('transforms `array` type schemas with `enum` (with an `array` type with `enum`)', () => {
487
- const schema = {
488
- type: 'array',
489
- enum: [
490
- {
491
- type: 'array',
492
- enum: [
493
- {},
494
- {},
495
- {}
496
- ]
497
- }
498
- ]
499
- }
500
-
501
- expect(transform(schema))
502
- .to.eql({
503
- meta: {
504
- type: 'array',
505
- uri: '#/',
506
- rootSchema: {},
507
- schema,
508
- items: [
509
- {
510
- type: 'array',
511
- enum: [
512
- {},
513
- {},
514
- {}
515
- ]
516
- }
517
- ],
518
- selectedItems: []
519
- },
520
- elements: {
521
- enum: {
522
- id: '#/',
523
- items: [
524
- {
525
- type: 'array',
526
- enum: [
527
- {},
528
- {},
529
- {}
530
- ]
531
- }
532
- ],
533
- selectedItems: []
534
- }
535
- }
536
- })
537
- })
538
-
539
- it('transforms `array` type schemas with `enum` (with an `array` type with `anyOf`)', () => {
540
- const schema = {
541
- type: 'array',
542
- enum: [
543
- {
544
- type: 'array',
545
- anyOf: [
546
- {
547
- type: 'array'
548
- }
549
- ]
550
- }
551
- ]
552
- }
553
-
554
- expect(transform(schema))
555
- .to.eql({
556
- meta: {
557
- type: 'array',
558
- uri: '#/',
559
- rootSchema: {},
560
- schema,
561
- items: [
562
- {
563
- type: 'array',
564
- anyOf: [
565
- {
566
- type: 'array'
567
- }
568
- ]
569
- }
570
- ],
571
- selectedItems: []
572
- },
573
- elements: {
574
- enum: {
575
- id: '#/',
576
- items: [
577
- {
578
- type: 'array',
579
- anyOf: [
580
- {
581
- type: 'array'
582
- }
583
- ]
584
- }
585
- ],
586
- selectedItems: []
587
- }
588
- }
589
- })
590
- })
591
-
592
- it('transforms `array` type schemas with `enum` (with an `array` type with `oneOf`)', () => {
593
- const schema = {
594
- type: 'array',
595
- enum: [
596
- {
597
- type: 'array',
598
- oneOf: [
599
- {
600
- type: 'array'
601
- }
602
- ]
603
- }
604
- ]
605
- }
606
-
607
- expect(transform(schema))
608
- .to.eql({
609
- meta: {
610
- type: 'array',
611
- uri: '#/',
612
- rootSchema: {},
613
- schema,
614
- items: [
615
- {
616
- type: 'array',
617
- oneOf: [
618
- {
619
- type: 'array'
620
- }
621
- ]
622
- }
623
- ],
624
- selectedItems: []
625
- },
626
- elements: {
627
- enum: {
628
- id: '#/',
629
- items: [
630
- {
631
- type: 'array',
632
- oneOf: [
633
- {
634
- type: 'array'
635
- }
636
- ]
637
- }
638
- ],
639
- selectedItems: []
640
- }
641
- }
642
- })
643
- })
644
-
645
- it('transforms `array` type schemas with `enum` (with an `array` type with `allOf`)', () => {
646
- const schema = {
647
- type: 'array',
648
- enum: [
649
- {
650
- type: 'array',
651
- allOf: [
652
- {
653
- type: 'array'
654
- }
655
- ]
656
- }
657
- ]
658
- }
659
-
660
- expect(transform(schema))
661
- .to.eql({
662
- meta: {
663
- type: 'array',
664
- uri: '#/',
665
- rootSchema: {},
666
- schema,
667
- items: [
668
- {
669
- type: 'array',
670
- allOf: [
671
- {
672
- type: 'array'
673
- }
674
- ]
675
- }
676
- ],
677
- selectedItems: []
678
- },
679
- elements: {
680
- enum: {
681
- id: '#/',
682
- items: [
683
- {
684
- type: 'array',
685
- allOf: [
686
- {
687
- type: 'array'
688
- }
689
- ]
690
- }
691
- ],
692
- selectedItems: []
693
- }
694
- }
695
- })
696
- })
697
-
698
- it('transforms `array` type schemas with `anyOf` (with an `array` type with `enum`)', () => {
699
- const schema = {
700
- type: 'array',
701
- anyOf: [
702
- {
703
- type: 'array',
704
- enum: [
705
- {},
706
- {},
707
- {}
708
- ]
709
- }
710
- ]
711
- }
712
-
713
- expect(transform(schema))
714
- .to.eql({
715
- meta: {
716
- type: 'array',
717
- uri: '#/',
718
- rootSchema: {},
719
- schema,
720
- items: [
721
- {
722
- meta: {
723
- type: 'array',
724
- item: 0,
725
- parentUri: '#/',
726
- uri: '#/0',
727
- rootSchema: {},
728
- schema: {
729
- type: 'array',
730
- enum: [
731
- {},
732
- {},
733
- {}
734
- ]
735
- },
736
- items: [
737
- {},
738
- {},
739
- {}
740
- ],
741
- selectedItems: []
742
- },
743
- elements: {
744
- enum: {
745
- id: '#/0',
746
- items: [
747
- {},
748
- {},
749
- {}
750
- ],
751
- selectedItems: []
752
- }
753
- }
754
- }
755
- ],
756
- selectedItems: []
757
- },
758
- elements: {
759
- anyOf: {
760
- id: '#/',
761
- items: [
762
- {
763
- meta: {
764
- type: 'array',
765
- item: 0,
766
- parentUri: '#/',
767
- uri: '#/0',
768
- rootSchema: {},
769
- schema: {
770
- type: 'array',
771
- enum: [
772
- {},
773
- {},
774
- {}
775
- ]
776
- },
777
- items: [
778
- {},
779
- {},
780
- {}
781
- ],
782
- selectedItems: []
783
- },
784
- elements: {
785
- enum: {
786
- id: '#/0',
787
- items: [
788
- {},
789
- {},
790
- {}
791
- ],
792
- selectedItems: []
793
- }
794
- }
795
- }
796
- ],
797
- selectedItems: []
798
- }
799
- }
800
- })
801
- })
802
-
803
- it('transforms `array` type schemas with `anyOf` (with an `array` type with `anyOf`)', () => {
804
- const schema = {
805
- type: 'array',
806
- anyOf: [
807
- {
808
- type: 'array',
809
- anyOf: [
810
- {
811
- type: 'array'
812
- }
813
- ]
814
- }
815
- ]
816
- }
817
-
818
- expect(transform(schema))
819
- .to.eql({
820
- meta: {
821
- type: 'array',
822
- uri: '#/',
823
- rootSchema: {},
824
- schema,
825
- items: [
826
- {
827
- meta: {
828
- type: 'array',
829
- item: 0,
830
- parentUri: '#/',
831
- uri: '#/0',
832
- rootSchema: {},
833
- schema: {
834
- type: 'array',
835
- anyOf: [
836
- {
837
- type: 'array'
838
- }
839
- ]
840
- },
841
- items: [
842
- {
843
- meta: {
844
- type: 'array',
845
- item: 0,
846
- parentUri: '#/0',
847
- uri: '#/0/0',
848
- rootSchema: {},
849
- schema: {
850
- type: 'array'
851
- }
852
- },
853
- elements: {
854
- fields: []
855
- }
856
- }
857
- ],
858
- selectedItems: []
859
- },
860
- elements: {
861
- anyOf: {
862
- id: '#/0',
863
- items: [
864
- {
865
- meta: {
866
- type: 'array',
867
- item: 0,
868
- parentUri: '#/0',
869
- uri: '#/0/0',
870
- rootSchema: {},
871
- schema: {
872
- type: 'array'
873
- }
874
- },
875
- elements: {
876
- fields: []
877
- }
878
- }
879
- ],
880
- selectedItems: []
881
- }
882
- }
883
- }
884
- ],
885
- selectedItems: []
886
- },
887
- elements: {
888
- anyOf: {
889
- id: '#/',
890
- items: [
891
- {
892
- meta: {
893
- type: 'array',
894
- item: 0,
895
- parentUri: '#/',
896
- uri: '#/0',
897
- rootSchema: {},
898
- schema: {
899
- type: 'array',
900
- anyOf: [
901
- {
902
- type: 'array'
903
- }
904
- ]
905
- },
906
- items: [
907
- {
908
- meta: {
909
- type: 'array',
910
- item: 0,
911
- parentUri: '#/0',
912
- uri: '#/0/0',
913
- rootSchema: {},
914
- schema: {
915
- type: 'array'
916
- }
917
- },
918
- elements: {
919
- fields: []
920
- }
921
- }
922
- ],
923
- selectedItems: []
924
- },
925
- elements: {
926
- anyOf: {
927
- id: '#/0',
928
- items: [
929
- {
930
- meta: {
931
- type: 'array',
932
- item: 0,
933
- parentUri: '#/0',
934
- uri: '#/0/0',
935
- rootSchema: {},
936
- schema: {
937
- type: 'array'
938
- }
939
- },
940
- elements: {
941
- fields: []
942
- }
943
- }
944
- ],
945
- selectedItems: []
946
- }
947
- }
948
- }
949
- ],
950
- selectedItems: []
951
- }
952
- }
953
- })
954
- })
955
-
956
- it('transforms `array` type schemas with `anyOf` (with an `array` type with `oneOf`)', () => {
957
- const schema = {
958
- type: 'array',
959
- anyOf: [
960
- {
961
- type: 'array',
962
- oneOf: [
963
- {
964
- type: 'array'
965
- }
966
- ]
967
- }
968
- ]
969
- }
970
-
971
- expect(transform(schema))
972
- .to.eql({
973
- meta: {
974
- type: 'array',
975
- uri: '#/',
976
- rootSchema: {},
977
- schema,
978
- items: [
979
- {
980
- meta: {
981
- type: 'array',
982
- item: 0,
983
- parentUri: '#/',
984
- uri: '#/0',
985
- rootSchema: {},
986
- schema: {
987
- type: 'array',
988
- oneOf: [
989
- {
990
- type: 'array'
991
- }
992
- ]
993
- },
994
- items: [
995
- {
996
- meta: {
997
- type: 'array',
998
- item: 0,
999
- parentUri: '#/0',
1000
- uri: '#/0/0',
1001
- rootSchema: {},
1002
- schema: {
1003
- type: 'array'
1004
- }
1005
- },
1006
- elements: {
1007
- fields: []
1008
- }
1009
- }
1010
- ],
1011
- selectedItems: []
1012
- },
1013
- elements: {
1014
- oneOf: {
1015
- id: '#/0',
1016
- items: [
1017
- {
1018
- meta: {
1019
- type: 'array',
1020
- item: 0,
1021
- parentUri: '#/0',
1022
- uri: '#/0/0',
1023
- rootSchema: {},
1024
- schema: {
1025
- type: 'array'
1026
- }
1027
- },
1028
- elements: {
1029
- fields: []
1030
- }
1031
- }
1032
- ],
1033
- selectedItems: []
1034
- }
1035
- }
1036
- }
1037
- ],
1038
- selectedItems: []
1039
- },
1040
- elements: {
1041
- anyOf: {
1042
- id: '#/',
1043
- items: [
1044
- {
1045
- meta: {
1046
- type: 'array',
1047
- item: 0,
1048
- parentUri: '#/',
1049
- uri: '#/0',
1050
- rootSchema: {},
1051
- schema: {
1052
- type: 'array',
1053
- oneOf: [
1054
- {
1055
- type: 'array'
1056
- }
1057
- ]
1058
- },
1059
- items: [
1060
- {
1061
- meta: {
1062
- type: 'array',
1063
- item: 0,
1064
- parentUri: '#/0',
1065
- uri: '#/0/0',
1066
- rootSchema: {},
1067
- schema: {
1068
- type: 'array'
1069
- }
1070
- },
1071
- elements: {
1072
- fields: []
1073
- }
1074
- }
1075
- ],
1076
- selectedItems: []
1077
- },
1078
- elements: {
1079
- oneOf: {
1080
- id: '#/0',
1081
- items: [
1082
- {
1083
- meta: {
1084
- type: 'array',
1085
- item: 0,
1086
- parentUri: '#/0',
1087
- uri: '#/0/0',
1088
- rootSchema: {},
1089
- schema: {
1090
- type: 'array'
1091
- }
1092
- },
1093
- elements: {
1094
- fields: []
1095
- }
1096
- }
1097
- ],
1098
- selectedItems: []
1099
- }
1100
- }
1101
- }
1102
- ],
1103
- selectedItems: []
1104
- }
1105
- }
1106
- })
1107
- })
1108
-
1109
- it('transforms `array` type schemas with `anyOf` (with an `array` type with `allOf`)', () => {
1110
- const schema = {
1111
- type: 'array',
1112
- anyOf: [
1113
- {
1114
- type: 'array',
1115
- allOf: [
1116
- {
1117
- type: 'array'
1118
- }
1119
- ]
1120
- }
1121
- ]
1122
- }
1123
-
1124
- expect(transform(schema))
1125
- .to.eql({
1126
- meta: {
1127
- type: 'array',
1128
- uri: '#/',
1129
- rootSchema: {},
1130
- schema,
1131
- items: [
1132
- {
1133
- meta: {
1134
- type: 'array',
1135
- item: 0,
1136
- parentUri: '#/',
1137
- uri: '#/0',
1138
- rootSchema: {},
1139
- schema: {
1140
- type: 'array',
1141
- allOf: [
1142
- {
1143
- type: 'array'
1144
- }
1145
- ]
1146
- }
1147
- },
1148
- elements: {
1149
- field: {
1150
- id: '#/0'
1151
- }
1152
- }
1153
- }
1154
- ],
1155
- selectedItems: []
1156
- },
1157
- elements: {
1158
- anyOf: {
1159
- id: '#/',
1160
- items: [
1161
- {
1162
- meta: {
1163
- type: 'array',
1164
- item: 0,
1165
- parentUri: '#/',
1166
- uri: '#/0',
1167
- rootSchema: {},
1168
- schema: {
1169
- type: 'array',
1170
- allOf: [
1171
- {
1172
- type: 'array'
1173
- }
1174
- ]
1175
- }
1176
- },
1177
- elements: {
1178
- field: {
1179
- id: '#/0'
1180
- }
1181
- }
1182
- }
1183
- ],
1184
- selectedItems: []
1185
- }
1186
- }
1187
- })
1188
- })
1189
-
1190
- it('transforms `array` type schemas with `oneOf` (with an `array` type with `enum`)', () => {
1191
- const schema = {
1192
- type: 'array',
1193
- oneOf: [
1194
- {
1195
- type: 'array',
1196
- enum: [
1197
- {},
1198
- {},
1199
- {}
1200
- ]
1201
- }
1202
- ]
1203
- }
1204
-
1205
- expect(transform(schema))
1206
- .to.eql({
1207
- meta: {
1208
- type: 'array',
1209
- uri: '#/',
1210
- rootSchema: {},
1211
- schema,
1212
- items: [
1213
- {
1214
- meta: {
1215
- type: 'array',
1216
- item: 0,
1217
- parentUri: '#/',
1218
- uri: '#/0',
1219
- rootSchema: {},
1220
- schema: {
1221
- type: 'array',
1222
- enum: [
1223
- {},
1224
- {},
1225
- {}
1226
- ]
1227
- },
1228
- items: [
1229
- {},
1230
- {},
1231
- {}
1232
- ],
1233
- selectedItems: []
1234
- },
1235
- elements: {
1236
- enum: {
1237
- id: '#/0',
1238
- items: [
1239
- {},
1240
- {},
1241
- {}
1242
- ],
1243
- selectedItems: []
1244
- }
1245
- }
1246
- }
1247
- ],
1248
- selectedItems: []
1249
- },
1250
- elements: {
1251
- oneOf: {
1252
- id: '#/',
1253
- items: [
1254
- {
1255
- meta: {
1256
- type: 'array',
1257
- item: 0,
1258
- parentUri: '#/',
1259
- uri: '#/0',
1260
- rootSchema: {},
1261
- schema: {
1262
- type: 'array',
1263
- enum: [
1264
- {},
1265
- {},
1266
- {}
1267
- ]
1268
- },
1269
- items: [
1270
- {},
1271
- {},
1272
- {}
1273
- ],
1274
- selectedItems: []
1275
- },
1276
- elements: {
1277
- enum: {
1278
- id: '#/0',
1279
- items: [
1280
- {},
1281
- {},
1282
- {}
1283
- ],
1284
- selectedItems: []
1285
- }
1286
- }
1287
- }
1288
- ],
1289
- selectedItems: []
1290
- }
1291
- }
1292
- })
1293
- })
1294
-
1295
- it('transforms `array` type schemas with `oneOf` (with an `array` type with `anyOf`)', () => {
1296
- const schema = {
1297
- type: 'array',
1298
- oneOf: [
1299
- {
1300
- type: 'array',
1301
- anyOf: [
1302
- {
1303
- type: 'array'
1304
- }
1305
- ]
1306
- }
1307
- ]
1308
- }
1309
-
1310
- expect(transform(schema))
1311
- .to.eql({
1312
- meta: {
1313
- type: 'array',
1314
- uri: '#/',
1315
- rootSchema: {},
1316
- schema,
1317
- items: [
1318
- {
1319
- meta: {
1320
- type: 'array',
1321
- item: 0,
1322
- parentUri: '#/',
1323
- uri: '#/0',
1324
- rootSchema: {},
1325
- schema: {
1326
- type: 'array',
1327
- anyOf: [
1328
- {
1329
- type: 'array'
1330
- }
1331
- ]
1332
- },
1333
- items: [
1334
- {
1335
- meta: {
1336
- type: 'array',
1337
- item: 0,
1338
- parentUri: '#/0',
1339
- uri: '#/0/0',
1340
- rootSchema: {},
1341
- schema: {
1342
- type: 'array'
1343
- }
1344
- },
1345
- elements: {
1346
- fields: []
1347
- }
1348
- }
1349
- ],
1350
- selectedItems: []
1351
- },
1352
- elements: {
1353
- anyOf: {
1354
- id: '#/0',
1355
- items: [
1356
- {
1357
- meta: {
1358
- type: 'array',
1359
- item: 0,
1360
- parentUri: '#/0',
1361
- uri: '#/0/0',
1362
- rootSchema: {},
1363
- schema: {
1364
- type: 'array'
1365
- }
1366
- },
1367
- elements: {
1368
- fields: []
1369
- }
1370
- }
1371
- ],
1372
- selectedItems: []
1373
- }
1374
- }
1375
- }
1376
- ],
1377
- selectedItems: []
1378
- },
1379
- elements: {
1380
- oneOf: {
1381
- id: '#/',
1382
- items: [
1383
- {
1384
- meta: {
1385
- type: 'array',
1386
- item: 0,
1387
- parentUri: '#/',
1388
- uri: '#/0',
1389
- rootSchema: {},
1390
- schema: {
1391
- type: 'array',
1392
- anyOf: [
1393
- {
1394
- type: 'array'
1395
- }
1396
- ]
1397
- },
1398
- items: [
1399
- {
1400
- meta: {
1401
- type: 'array',
1402
- item: 0,
1403
- parentUri: '#/0',
1404
- uri: '#/0/0',
1405
- rootSchema: {},
1406
- schema: {
1407
- type: 'array'
1408
- }
1409
- },
1410
- elements: {
1411
- fields: []
1412
- }
1413
- }
1414
- ],
1415
- selectedItems: []
1416
- },
1417
- elements: {
1418
- anyOf: {
1419
- id: '#/0',
1420
- items: [
1421
- {
1422
- meta: {
1423
- type: 'array',
1424
- item: 0,
1425
- parentUri: '#/0',
1426
- uri: '#/0/0',
1427
- rootSchema: {},
1428
- schema: {
1429
- type: 'array'
1430
- }
1431
- },
1432
- elements: {
1433
- fields: []
1434
- }
1435
- }
1436
- ],
1437
- selectedItems: []
1438
- }
1439
- }
1440
- }
1441
- ],
1442
- selectedItems: []
1443
- }
1444
- }
1445
- })
1446
- })
1447
-
1448
- it('transforms `array` type schemas with `oneOf` (with an `array` type with `oneOf`)', () => {
1449
- const schema = {
1450
- type: 'array',
1451
- oneOf: [
1452
- {
1453
- type: 'array',
1454
- oneOf: [
1455
- {
1456
- type: 'array'
1457
- }
1458
- ]
1459
- }
1460
- ]
1461
- }
1462
-
1463
- expect(transform(schema))
1464
- .to.eql({
1465
- meta: {
1466
- type: 'array',
1467
- uri: '#/',
1468
- rootSchema: {},
1469
- schema,
1470
- items: [
1471
- {
1472
- meta: {
1473
- type: 'array',
1474
- item: 0,
1475
- parentUri: '#/',
1476
- uri: '#/0',
1477
- rootSchema: {},
1478
- schema: {
1479
- type: 'array',
1480
- oneOf: [
1481
- {
1482
- type: 'array'
1483
- }
1484
- ]
1485
- },
1486
- items: [
1487
- {
1488
- meta: {
1489
- type: 'array',
1490
- item: 0,
1491
- parentUri: '#/0',
1492
- uri: '#/0/0',
1493
- rootSchema: {},
1494
- schema: {
1495
- type: 'array'
1496
- }
1497
- },
1498
- elements: {
1499
- fields: []
1500
- }
1501
- }
1502
- ],
1503
- selectedItems: []
1504
- },
1505
- elements: {
1506
- oneOf: {
1507
- id: '#/0',
1508
- items: [
1509
- {
1510
- meta: {
1511
- type: 'array',
1512
- item: 0,
1513
- parentUri: '#/0',
1514
- uri: '#/0/0',
1515
- rootSchema: {},
1516
- schema: {
1517
- type: 'array'
1518
- }
1519
- },
1520
- elements: {
1521
- fields: []
1522
- }
1523
- }
1524
- ],
1525
- selectedItems: []
1526
- }
1527
- }
1528
- }
1529
- ],
1530
- selectedItems: []
1531
- },
1532
- elements: {
1533
- oneOf: {
1534
- id: '#/',
1535
- items: [
1536
- {
1537
- meta: {
1538
- type: 'array',
1539
- item: 0,
1540
- parentUri: '#/',
1541
- uri: '#/0',
1542
- rootSchema: {},
1543
- schema: {
1544
- type: 'array',
1545
- oneOf: [
1546
- {
1547
- type: 'array'
1548
- }
1549
- ]
1550
- },
1551
- items: [
1552
- {
1553
- meta: {
1554
- type: 'array',
1555
- item: 0,
1556
- parentUri: '#/0',
1557
- uri: '#/0/0',
1558
- rootSchema: {},
1559
- schema: {
1560
- type: 'array'
1561
- }
1562
- },
1563
- elements: {
1564
- fields: []
1565
- }
1566
- }
1567
- ],
1568
- selectedItems: []
1569
- },
1570
- elements: {
1571
- oneOf: {
1572
- id: '#/0',
1573
- items: [
1574
- {
1575
- meta: {
1576
- type: 'array',
1577
- item: 0,
1578
- parentUri: '#/0',
1579
- uri: '#/0/0',
1580
- rootSchema: {},
1581
- schema: {
1582
- type: 'array'
1583
- }
1584
- },
1585
- elements: {
1586
- fields: []
1587
- }
1588
- }
1589
- ],
1590
- selectedItems: []
1591
- }
1592
- }
1593
- }
1594
- ],
1595
- selectedItems: []
1596
- }
1597
- }
1598
- })
1599
- })
1600
-
1601
- it('transforms `array` type schemas with `oneOf` (with an `array` type with `allOf`)', () => {
1602
- const schema = {
1603
- type: 'array',
1604
- oneOf: [
1605
- {
1606
- type: 'array',
1607
- allOf: [
1608
- {
1609
- type: 'array'
1610
- }
1611
- ]
1612
- }
1613
- ]
1614
- }
1615
-
1616
- expect(transform(schema))
1617
- .to.eql({
1618
- meta: {
1619
- type: 'array',
1620
- uri: '#/',
1621
- rootSchema: {},
1622
- schema,
1623
- items: [
1624
- {
1625
- meta: {
1626
- type: 'array',
1627
- item: 0,
1628
- parentUri: '#/',
1629
- uri: '#/0',
1630
- rootSchema: {},
1631
- schema: {
1632
- type: 'array',
1633
- allOf: [
1634
- {
1635
- type: 'array'
1636
- }
1637
- ]
1638
- }
1639
- },
1640
- elements: {
1641
- field: {
1642
- id: '#/0'
1643
- }
1644
- }
1645
- }
1646
- ],
1647
- selectedItems: []
1648
- },
1649
- elements: {
1650
- oneOf: {
1651
- id: '#/',
1652
- items: [
1653
- {
1654
- meta: {
1655
- type: 'array',
1656
- item: 0,
1657
- parentUri: '#/',
1658
- uri: '#/0',
1659
- rootSchema: {},
1660
- schema: {
1661
- type: 'array',
1662
- allOf: [
1663
- {
1664
- type: 'array'
1665
- }
1666
- ]
1667
- }
1668
- },
1669
- elements: {
1670
- field: {
1671
- id: '#/0'
1672
- }
1673
- }
1674
- }
1675
- ],
1676
- selectedItems: []
1677
- }
1678
- }
1679
- })
1680
- })
1681
-
1682
- it('transforms `array` type schemas with `allOf` (with an `array` type with `enum`)', () => {
1683
- const schema = {
1684
- type: 'array',
1685
- allOf: [
1686
- {
1687
- type: 'array',
1688
- enum: [
1689
- {},
1690
- {},
1691
- {}
1692
- ]
1693
- }
1694
- ]
1695
- }
1696
-
1697
- expect(transform(schema))
1698
- .to.eql({
1699
- meta: {
1700
- type: 'array',
1701
- uri: '#/',
1702
- rootSchema: {},
1703
- schema
1704
- },
1705
- elements: {
1706
- field: {
1707
- id: '#/'
1708
- }
1709
- }
1710
- })
1711
- })
1712
-
1713
- it('transforms `array` type schemas with `allOf` (with an `array` type with `anyOf`)', () => {
1714
- const schema = {
1715
- type: 'array',
1716
- allOf: [
1717
- {
1718
- type: 'array',
1719
- anyOf: [
1720
- {
1721
- type: 'array'
1722
- }
1723
- ]
1724
- }
1725
- ]
1726
- }
1727
-
1728
- expect(transform(schema))
1729
- .to.eql({
1730
- meta: {
1731
- type: 'array',
1732
- uri: '#/',
1733
- rootSchema: {},
1734
- schema
1735
- },
1736
- elements: {
1737
- field: {
1738
- id: '#/'
1739
- }
1740
- }
1741
- })
1742
- })
1743
-
1744
- it('transforms `array` type schemas with `allOf` (with an `array` type with `oneOf`)', () => {
1745
- const schema = {
1746
- type: 'array',
1747
- allOf: [
1748
- {
1749
- type: 'array',
1750
- oneOf: [
1751
- {
1752
- type: 'array'
1753
- }
1754
- ]
1755
- }
1756
- ]
1757
- }
1758
-
1759
- expect(transform(schema))
1760
- .to.eql({
1761
- meta: {
1762
- type: 'array',
1763
- uri: '#/',
1764
- rootSchema: {},
1765
- schema
1766
- },
1767
- elements: {
1768
- field: {
1769
- id: '#/'
1770
- }
1771
- }
1772
- })
1773
- })
1774
-
1775
- it('transforms `array` type schemas with `allOf` (with an `array` type with `allOf`)', () => {
1776
- const schema = {
1777
- type: 'array',
1778
- allOf: [
1779
- {
1780
- type: 'array',
1781
- allOf: [
1782
- {
1783
- type: 'array'
1784
- }
1785
- ]
1786
- }
1787
- ]
1788
- }
1789
-
1790
- expect(transform(schema))
1791
- .to.eql({
1792
- meta: {
1793
- type: 'array',
1794
- uri: '#/',
1795
- rootSchema: {},
1796
- schema
1797
- },
1798
- elements: {
1799
- field: {
1800
- id: '#/'
1801
- }
1802
- }
1803
- })
1804
- })
1805
- })
1806
- })