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