@jsonforms/core 3.1.0-alpha.0 → 3.1.0-alpha.1
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/lib/Helpers.d.ts +1 -1
- package/lib/actions/actions.d.ts +6 -5
- package/lib/generators/Generate.d.ts +1 -1
- package/lib/generators/schema.d.ts +1 -1
- package/lib/i18n/i18nTypes.d.ts +3 -2
- package/lib/i18n/i18nUtil.d.ts +2 -2
- package/lib/jsonforms-core.cjs.js +3 -3
- package/lib/jsonforms-core.cjs.js.map +1 -1
- package/lib/jsonforms-core.esm.js +2 -2
- package/lib/jsonforms-core.esm.js.map +1 -1
- package/lib/models/jsonSchema.d.ts +2 -2
- package/lib/models/uischema.d.ts +1 -1
- package/lib/reducers/cells.d.ts +2 -2
- package/lib/reducers/config.d.ts +1 -1
- package/lib/reducers/core.d.ts +3 -2
- package/lib/reducers/default-data.d.ts +1 -1
- package/lib/reducers/i18n.d.ts +1 -1
- package/lib/reducers/reducers.d.ts +4 -4
- package/lib/reducers/renderers.d.ts +2 -2
- package/lib/reducers/selectors.d.ts +6 -6
- package/lib/reducers/uischemas.d.ts +2 -2
- package/lib/store.d.ts +3 -3
- package/lib/testers/testers.d.ts +1 -1
- package/lib/util/cell.d.ts +3 -3
- package/lib/util/combinators.d.ts +1 -1
- package/lib/util/label.d.ts +1 -1
- package/lib/util/path.d.ts +6 -3
- package/lib/util/renderer.d.ts +5 -5
- package/lib/util/resolvers.d.ts +1 -1
- package/lib/util/runtime.d.ts +2 -2
- package/lib/util/util.d.ts +2 -2
- package/lib/util/validator.d.ts +1 -1
- package/package.json +7 -3
- package/src/Helpers.ts +1 -1
- package/src/actions/actions.ts +6 -5
- package/src/generators/Generate.ts +1 -1
- package/src/generators/schema.ts +1 -1
- package/src/i18n/i18nTypes.ts +3 -2
- package/src/i18n/i18nUtil.ts +2 -2
- package/src/models/jsonSchema.ts +2 -2
- package/src/models/uischema.ts +1 -1
- package/src/reducers/cells.ts +2 -2
- package/src/reducers/config.ts +1 -1
- package/src/reducers/core.ts +4 -3
- package/src/reducers/default-data.ts +1 -1
- package/src/reducers/i18n.ts +1 -1
- package/src/reducers/reducers.ts +4 -4
- package/src/reducers/renderers.ts +2 -2
- package/src/reducers/selectors.ts +6 -6
- package/src/reducers/uischemas.ts +2 -2
- package/src/store.ts +3 -3
- package/src/testers/testers.ts +2 -2
- package/src/util/cell.ts +3 -3
- package/src/util/combinators.ts +1 -1
- package/src/util/label.ts +1 -1
- package/src/util/path.ts +6 -3
- package/src/util/renderer.ts +5 -5
- package/src/util/resolvers.ts +2 -2
- package/src/util/runtime.ts +2 -2
- package/src/util/util.ts +2 -2
- package/src/util/validator.ts +1 -1
- package/.nycrc +0 -6
- package/docs/assets/css/main.css +0 -1
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -51
- package/docs/assets/js/search.json +0 -1
- package/docs/classes/gen.html +0 -406
- package/docs/enums/ruleeffect.html +0 -214
- package/docs/globals.html +0 -10568
- package/docs/index.html +0 -1297
- package/docs/interfaces/action.html +0 -166
- package/docs/interfaces/addcellrendereraction.html +0 -181
- package/docs/interfaces/addrendereraction.html +0 -181
- package/docs/interfaces/adduischemaaction.html +0 -181
- package/docs/interfaces/andcondition.html +0 -181
- package/docs/interfaces/anyaction.html +0 -189
- package/docs/interfaces/arraycontrolprops.html +0 -653
- package/docs/interfaces/arraylayoutprops.html +0 -648
- package/docs/interfaces/categorization.html +0 -281
- package/docs/interfaces/category.html +0 -279
- package/docs/interfaces/cellprops.html +0 -452
- package/docs/interfaces/combinatorrendererprops.html +0 -503
- package/docs/interfaces/combinatorsubschemarenderinfo.html +0 -181
- package/docs/interfaces/composablecondition.html +0 -193
- package/docs/interfaces/condition.html +0 -176
- package/docs/interfaces/controlelement.html +0 -280
- package/docs/interfaces/controlprops.html +0 -497
- package/docs/interfaces/controlstate.html +0 -184
- package/docs/interfaces/controlwithdetailprops.html +0 -501
- package/docs/interfaces/dispatchcellprops.html +0 -388
- package/docs/interfaces/dispatchcellstateprops.html +0 -408
- package/docs/interfaces/dispatchpropsofarraycontrol.html +0 -322
- package/docs/interfaces/dispatchpropsofcontrol.html +0 -204
- package/docs/interfaces/dispatchpropsofmultienumcontrol.html +0 -215
- package/docs/interfaces/enumcellprops.html +0 -467
- package/docs/interfaces/enumoption.html +0 -167
- package/docs/interfaces/formatted.html +0 -226
- package/docs/interfaces/grouplayout.html +0 -284
- package/docs/interfaces/horizontallayout.html +0 -234
- package/docs/interfaces/initaction.html +0 -209
- package/docs/interfaces/initactionoptions.html +0 -181
- package/docs/interfaces/internationalizable.html +0 -170
- package/docs/interfaces/jsonformscellrendererregistryentry.html +0 -167
- package/docs/interfaces/jsonformscore.html +0 -251
- package/docs/interfaces/jsonformsdefaultdataregistryentry.html +0 -167
- package/docs/interfaces/jsonformsextendedstate.html +0 -175
- package/docs/interfaces/jsonformsi18nstate.html +0 -181
- package/docs/interfaces/jsonformsprops.html +0 -321
- package/docs/interfaces/jsonformsrendererregistryentry.html +0 -167
- package/docs/interfaces/jsonformsstate.html +0 -170
- package/docs/interfaces/jsonformsstore.html +0 -376
- package/docs/interfaces/jsonformssubstates.html +0 -276
- package/docs/interfaces/jsonformsuischemaregistryentry.html +0 -167
- package/docs/interfaces/jsonschema4.html +0 -758
- package/docs/interfaces/jsonschema7.html +0 -884
- package/docs/interfaces/labelable.html +0 -184
- package/docs/interfaces/labeldescription.html +0 -184
- package/docs/interfaces/labeled.html +0 -182
- package/docs/interfaces/labelelement.html +0 -251
- package/docs/interfaces/labelprops.html +0 -339
- package/docs/interfaces/layout.html +0 -253
- package/docs/interfaces/layoutprops.html +0 -359
- package/docs/interfaces/leafcondition.html +0 -209
- package/docs/interfaces/orcondition.html +0 -181
- package/docs/interfaces/ownpropsofcell.html +0 -321
- package/docs/interfaces/ownpropsofcontrol.html +0 -305
- package/docs/interfaces/ownpropsofenum.html +0 -161
- package/docs/interfaces/ownpropsofenumcell.html +0 -335
- package/docs/interfaces/ownpropsofjsonformsrenderer.html +0 -296
- package/docs/interfaces/ownpropsoflabel.html +0 -286
- package/docs/interfaces/ownpropsoflayout.html +0 -305
- package/docs/interfaces/ownpropsofmasterlistitem.html +0 -289
- package/docs/interfaces/ownpropsofrenderer.html +0 -292
- package/docs/interfaces/referenceschemamap.html +0 -138
- package/docs/interfaces/registerdefaultdataaction.html +0 -181
- package/docs/interfaces/removecellrendereraction.html +0 -181
- package/docs/interfaces/removerendereraction.html +0 -181
- package/docs/interfaces/removeuischemaaction.html +0 -167
- package/docs/interfaces/rendererprops.html +0 -331
- package/docs/interfaces/rule.html +0 -185
- package/docs/interfaces/schemabasedcondition.html +0 -202
- package/docs/interfaces/scopable.html +0 -171
- package/docs/interfaces/scoped.html +0 -183
- package/docs/interfaces/setajvaction.html +0 -167
- package/docs/interfaces/setconfigaction.html +0 -167
- package/docs/interfaces/setlocaleaction.html +0 -167
- package/docs/interfaces/setschemaaction.html +0 -167
- package/docs/interfaces/settranslatoraction.html +0 -181
- package/docs/interfaces/setuischemaaction.html +0 -167
- package/docs/interfaces/setvalidationmodeaction.html +0 -167
- package/docs/interfaces/statepropsofarraycontrol.html +0 -474
- package/docs/interfaces/statepropsofarraylayout.html +0 -461
- package/docs/interfaces/statepropsofcell.html +0 -408
- package/docs/interfaces/statepropsofcombinator.html +0 -449
- package/docs/interfaces/statepropsofcontrol.html +0 -451
- package/docs/interfaces/statepropsofcontrolwithdetail.html +0 -463
- package/docs/interfaces/statepropsofenumcell.html +0 -422
- package/docs/interfaces/statepropsofjsonformsrenderer.html +0 -324
- package/docs/interfaces/statepropsoflabel.html +0 -343
- package/docs/interfaces/statepropsoflayout.html +0 -369
- package/docs/interfaces/statepropsofmasteritem.html +0 -309
- package/docs/interfaces/statepropsofrenderer.html +0 -331
- package/docs/interfaces/statepropsofscopedrenderer.html +0 -391
- package/docs/interfaces/store.html +0 -386
- package/docs/interfaces/testercontext.html +0 -184
- package/docs/interfaces/uischemaelement.html +0 -225
- package/docs/interfaces/unregisterdefaultdataaction.html +0 -167
- package/docs/interfaces/updateaction.html +0 -202
- package/docs/interfaces/updatecoreaction.html +0 -209
- package/docs/interfaces/updateerrorsaction.html +0 -167
- package/docs/interfaces/updatei18naction.html +0 -195
- package/docs/interfaces/verticallayout.html +0 -234
- package/docs/interfaces/withclassname.html +0 -153
- package/rollup.config.js +0 -44
- package/stats.html +0 -3279
- package/test/actions/actions.test.ts +0 -93
- package/test/generators/schema.test.ts +0 -224
- package/test/generators/uischema.test.ts +0 -576
- package/test/i18n/i18nUtil.test.ts +0 -88
- package/test/reducers/core.test.ts +0 -1682
- package/test/reducers/uischemas.test.ts +0 -173
- package/test/testers.test.ts +0 -948
- package/test/util/array.test.ts +0 -28
- package/test/util/cell.test.ts +0 -354
- package/test/util/derivetype.test.ts +0 -101
- package/test/util/label.test.ts +0 -364
- package/test/util/path.test.ts +0 -259
- package/test/util/renderer.test.ts +0 -1830
- package/test/util/resolvers.test.ts +0 -157
- package/test/util/runtime.test.ts +0 -779
- package/tsconfig.json +0 -13
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import test from 'ava';
|
|
26
|
-
import {
|
|
27
|
-
Actions,
|
|
28
|
-
JsonSchema,
|
|
29
|
-
UISchemaElement,
|
|
30
|
-
ControlElement,
|
|
31
|
-
VerticalLayout
|
|
32
|
-
} from '../../src';
|
|
33
|
-
|
|
34
|
-
test('Init Action generates schema when not provided', t => {
|
|
35
|
-
const schema: JsonSchema = {
|
|
36
|
-
type: 'object',
|
|
37
|
-
properties: {
|
|
38
|
-
name: {
|
|
39
|
-
type: 'string'
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
additionalProperties: true,
|
|
43
|
-
required: ['name']
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
const init = Actions.init({ name: 'foobar' });
|
|
47
|
-
t.deepEqual(init.schema, schema);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('Init Action generates ui schema when not provided', t => {
|
|
51
|
-
const schema: JsonSchema = {
|
|
52
|
-
type: 'object',
|
|
53
|
-
properties: {
|
|
54
|
-
name: {
|
|
55
|
-
type: 'string'
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
const uischema: VerticalLayout = {
|
|
60
|
-
type: 'VerticalLayout',
|
|
61
|
-
elements: [
|
|
62
|
-
{
|
|
63
|
-
type: 'Control',
|
|
64
|
-
scope: '#/properties/name'
|
|
65
|
-
} as ControlElement
|
|
66
|
-
]
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const init = Actions.init({}, schema);
|
|
70
|
-
t.deepEqual(init.uischema, uischema);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
test('Init Action generates ui schema when not valid', t => {
|
|
74
|
-
const schema: JsonSchema = {
|
|
75
|
-
type: 'object',
|
|
76
|
-
properties: {
|
|
77
|
-
name: {
|
|
78
|
-
type: 'string'
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const init = Actions.init({}, schema, false as any);
|
|
84
|
-
t.deepEqual(init.uischema, {
|
|
85
|
-
type: 'VerticalLayout',
|
|
86
|
-
elements: [
|
|
87
|
-
{
|
|
88
|
-
type: 'Control',
|
|
89
|
-
scope: '#/properties/name'
|
|
90
|
-
}
|
|
91
|
-
]
|
|
92
|
-
} as UISchemaElement);
|
|
93
|
-
});
|
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
The MIT License
|
|
3
|
-
|
|
4
|
-
Copyright (c) 2017-2019 EclipseSource Munich
|
|
5
|
-
https://github.com/eclipsesource/jsonforms
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
in the Software without restriction, including without limitation the rights
|
|
10
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
furnished to do so, subject to the following conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be included in
|
|
15
|
-
all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
23
|
-
THE SOFTWARE.
|
|
24
|
-
*/
|
|
25
|
-
import test from 'ava';
|
|
26
|
-
|
|
27
|
-
import { generateJsonSchema } from '../../src/generators/schema';
|
|
28
|
-
|
|
29
|
-
test('default schema generation basic types', t => {
|
|
30
|
-
const instance: any = {
|
|
31
|
-
boolean: false,
|
|
32
|
-
number: 3.14,
|
|
33
|
-
integer: 3,
|
|
34
|
-
string: 'PI',
|
|
35
|
-
null: null,
|
|
36
|
-
undefined: undefined
|
|
37
|
-
};
|
|
38
|
-
const schema = generateJsonSchema(instance);
|
|
39
|
-
// FIXME: Should a property be generated for properties with undefined?
|
|
40
|
-
t.deepEqual(schema, {
|
|
41
|
-
type: 'object',
|
|
42
|
-
properties: {
|
|
43
|
-
boolean: {
|
|
44
|
-
type: 'boolean'
|
|
45
|
-
},
|
|
46
|
-
number: {
|
|
47
|
-
type: 'number'
|
|
48
|
-
},
|
|
49
|
-
integer: {
|
|
50
|
-
type: 'integer'
|
|
51
|
-
},
|
|
52
|
-
string: {
|
|
53
|
-
type: 'string'
|
|
54
|
-
},
|
|
55
|
-
null: {
|
|
56
|
-
type: 'null'
|
|
57
|
-
},
|
|
58
|
-
undefined: {}
|
|
59
|
-
},
|
|
60
|
-
additionalProperties: true,
|
|
61
|
-
required: ['boolean', 'number', 'integer', 'string', 'null', 'undefined']
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
test('default schema generation array types', t => {
|
|
65
|
-
const instance: any = {
|
|
66
|
-
emptyArray: [],
|
|
67
|
-
booleanArray: [false, false],
|
|
68
|
-
numberArray: [3.14, 2.71],
|
|
69
|
-
integerArray: [3, 2],
|
|
70
|
-
stringArray: ['PI', 'e'],
|
|
71
|
-
nullArray: [null, null]
|
|
72
|
-
};
|
|
73
|
-
const schema = generateJsonSchema(instance);
|
|
74
|
-
t.deepEqual(schema, {
|
|
75
|
-
type: 'object',
|
|
76
|
-
properties: {
|
|
77
|
-
emptyArray: {
|
|
78
|
-
type: 'array',
|
|
79
|
-
items: {}
|
|
80
|
-
},
|
|
81
|
-
booleanArray: {
|
|
82
|
-
type: 'array',
|
|
83
|
-
items: { type: 'boolean' }
|
|
84
|
-
},
|
|
85
|
-
numberArray: {
|
|
86
|
-
type: 'array',
|
|
87
|
-
items: { type: 'number' }
|
|
88
|
-
},
|
|
89
|
-
integerArray: {
|
|
90
|
-
type: 'array',
|
|
91
|
-
items: { type: 'integer' }
|
|
92
|
-
},
|
|
93
|
-
stringArray: {
|
|
94
|
-
type: 'array',
|
|
95
|
-
items: { type: 'string' }
|
|
96
|
-
},
|
|
97
|
-
nullArray: {
|
|
98
|
-
type: 'array',
|
|
99
|
-
items: { type: 'null' }
|
|
100
|
-
}
|
|
101
|
-
},
|
|
102
|
-
additionalProperties: true,
|
|
103
|
-
required: [
|
|
104
|
-
'emptyArray',
|
|
105
|
-
'booleanArray',
|
|
106
|
-
'numberArray',
|
|
107
|
-
'integerArray',
|
|
108
|
-
'stringArray',
|
|
109
|
-
'nullArray'
|
|
110
|
-
]
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
test.failing('default schema generation tuple array types', t => {
|
|
114
|
-
const instance: any = { tupleArray: [3.14, 'PI'] };
|
|
115
|
-
const schema = generateJsonSchema(instance);
|
|
116
|
-
// FIXME: This assumption is the correct one, but we crteate a oneOf in this case
|
|
117
|
-
t.deepEqual(schema, {
|
|
118
|
-
type: 'object',
|
|
119
|
-
properties: {
|
|
120
|
-
tupleArray: {
|
|
121
|
-
type: 'array',
|
|
122
|
-
items: [{ type: 'number' }, { type: 'string' }]
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
additionalProperties: true,
|
|
126
|
-
required: ['tupleArray']
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
test('default schema generation ', t => {
|
|
130
|
-
const instance: any = {
|
|
131
|
-
address: {
|
|
132
|
-
streetAddress: '21 2nd Street',
|
|
133
|
-
city: 'New York'
|
|
134
|
-
},
|
|
135
|
-
phoneNumber: [
|
|
136
|
-
{
|
|
137
|
-
location: 'home',
|
|
138
|
-
code: 44,
|
|
139
|
-
private: true
|
|
140
|
-
}
|
|
141
|
-
]
|
|
142
|
-
};
|
|
143
|
-
const schema = generateJsonSchema(instance);
|
|
144
|
-
t.deepEqual(schema, {
|
|
145
|
-
type: 'object',
|
|
146
|
-
properties: {
|
|
147
|
-
address: {
|
|
148
|
-
type: 'object',
|
|
149
|
-
properties: {
|
|
150
|
-
streetAddress: {
|
|
151
|
-
type: 'string'
|
|
152
|
-
},
|
|
153
|
-
city: {
|
|
154
|
-
type: 'string'
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
additionalProperties: true,
|
|
158
|
-
required: ['streetAddress', 'city']
|
|
159
|
-
},
|
|
160
|
-
phoneNumber: {
|
|
161
|
-
type: 'array',
|
|
162
|
-
items: {
|
|
163
|
-
type: 'object',
|
|
164
|
-
properties: {
|
|
165
|
-
location: {
|
|
166
|
-
type: 'string'
|
|
167
|
-
},
|
|
168
|
-
code: {
|
|
169
|
-
type: 'integer'
|
|
170
|
-
},
|
|
171
|
-
private: {
|
|
172
|
-
type: 'boolean'
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
additionalProperties: true,
|
|
176
|
-
required: ['location', 'code', 'private']
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
additionalProperties: true,
|
|
181
|
-
required: ['address', 'phoneNumber']
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
test('schema generation with options ', t => {
|
|
186
|
-
const instance: any = {
|
|
187
|
-
address: {
|
|
188
|
-
streetAddress: '21 2nd Street',
|
|
189
|
-
city: 'New York'
|
|
190
|
-
}
|
|
191
|
-
};
|
|
192
|
-
const schema = generateJsonSchema(instance, {
|
|
193
|
-
additionalProperties: false,
|
|
194
|
-
required: (props: string[]) => {
|
|
195
|
-
const keys = Object.keys(props);
|
|
196
|
-
if (props !== undefined && keys.length > 0) {
|
|
197
|
-
return [keys[0]];
|
|
198
|
-
} else {
|
|
199
|
-
return [];
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
t.deepEqual(schema, {
|
|
205
|
-
type: 'object',
|
|
206
|
-
properties: {
|
|
207
|
-
address: {
|
|
208
|
-
type: 'object',
|
|
209
|
-
properties: {
|
|
210
|
-
streetAddress: {
|
|
211
|
-
type: 'string'
|
|
212
|
-
},
|
|
213
|
-
city: {
|
|
214
|
-
type: 'string'
|
|
215
|
-
}
|
|
216
|
-
},
|
|
217
|
-
additionalProperties: false,
|
|
218
|
-
required: ['streetAddress']
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
additionalProperties: false,
|
|
222
|
-
required: ['address']
|
|
223
|
-
});
|
|
224
|
-
});
|