@trayio/tray-openapi 4.13.0 → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/OpenApiTypeDescriptors.d.ts +2 -0
- package/dist/OpenApiTypeDescriptors.d.ts.map +1 -1
- package/dist/OpenApiTypeDescriptors.js +2 -0
- package/dist/file-generators/GenerateHandler.d.ts.map +1 -1
- package/dist/file-generators/GenerateHandler.js +45 -6
- package/dist/file-generators/GenerateHandler.test.js +103 -245
- package/dist/file-generators/GenerateHandlerTest.d.ts.map +1 -1
- package/dist/file-generators/GenerateHandlerTest.js +17 -2
- package/dist/file-generators/GenerateHandlerTest.test.js +221 -295
- package/dist/file-generators/SchemaGenerator.d.ts +3 -0
- package/dist/file-generators/SchemaGenerator.d.ts.map +1 -0
- package/dist/file-generators/SchemaGenerator.js +44 -0
- package/dist/file-generators/types/GenerateInputSchema.d.ts.map +1 -1
- package/dist/file-generators/types/GenerateInputSchema.js +6 -0
- package/dist/file-generators/types/GenerateInputSchema.test.js +19 -95
- package/dist/file-generators/types/GenerateInputType.test.js +40 -192
- package/dist/file-generators/types/GenerateOutput.d.ts.map +1 -1
- package/dist/file-generators/types/GenerateOutput.js +2 -0
- package/dist/file-generators/types/GenerateOutput.test.js +21 -105
- package/dist/file-generators/types/JsonSchemaToTypescriptOptions.d.ts +1 -0
- package/dist/file-generators/types/JsonSchemaToTypescriptOptions.d.ts.map +1 -1
- package/dist/file-generators/types/JsonSchemaToTypescriptOptions.js +1 -0
- package/dist/templates/connector-template.zip +0 -0
- package/package.json +1 -1
|
@@ -26,92 +26,43 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
const E = __importStar(require("fp-ts/Either"));
|
|
27
27
|
const O = __importStar(require("fp-ts/Option"));
|
|
28
28
|
const GenerateHandlerTest_1 = require("./GenerateHandlerTest");
|
|
29
|
+
const SchemaGenerator_1 = require("./SchemaGenerator");
|
|
29
30
|
describe('GenerateHandlerTest', () => {
|
|
30
31
|
it('should generate a handler test with inputs and outputs', () => {
|
|
31
32
|
const input = {
|
|
32
33
|
operationNameCamelCase: 'getItem',
|
|
33
|
-
input: {
|
|
34
|
+
input: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
34
35
|
type: O.some('object'),
|
|
35
|
-
title: O.none,
|
|
36
36
|
properties: O.some({
|
|
37
|
-
id: {
|
|
38
|
-
title: O.none,
|
|
37
|
+
id: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
39
38
|
type: O.some('integer'),
|
|
40
|
-
format: 'int64',
|
|
41
|
-
properties: O.none,
|
|
42
|
-
required: O.none,
|
|
43
39
|
additionalProperties: O.some(false),
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
oneOf: O.none,
|
|
47
|
-
not: O.none,
|
|
48
|
-
in: O.none,
|
|
49
|
-
default: O.none,
|
|
50
|
-
},
|
|
51
|
-
name: {
|
|
52
|
-
title: O.none,
|
|
40
|
+
}),
|
|
41
|
+
name: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
53
42
|
type: O.some('string'),
|
|
54
|
-
properties: O.none,
|
|
55
|
-
required: O.none,
|
|
56
43
|
additionalProperties: O.some(false),
|
|
57
|
-
|
|
58
|
-
anyOf: O.none,
|
|
59
|
-
oneOf: O.none,
|
|
60
|
-
not: O.none,
|
|
61
|
-
in: O.none,
|
|
62
|
-
default: O.none,
|
|
63
|
-
},
|
|
44
|
+
}),
|
|
64
45
|
}),
|
|
65
46
|
required: O.some(['id', 'name']),
|
|
66
47
|
additionalProperties: O.some(false),
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
oneOf: O.none,
|
|
70
|
-
not: O.none,
|
|
71
|
-
in: O.none,
|
|
72
|
-
default: O.none,
|
|
73
|
-
},
|
|
74
|
-
output: {
|
|
48
|
+
}),
|
|
49
|
+
output: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
75
50
|
type: O.some('object'),
|
|
76
|
-
title: O.none,
|
|
77
51
|
properties: O.some({
|
|
78
|
-
id: {
|
|
52
|
+
id: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
79
53
|
title: O.none,
|
|
80
54
|
type: O.some('integer'),
|
|
81
|
-
format: 'int64',
|
|
82
|
-
properties: O.none,
|
|
83
|
-
required: O.none,
|
|
84
55
|
additionalProperties: O.some(false),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
oneOf: O.none,
|
|
88
|
-
not: O.none,
|
|
89
|
-
in: O.none,
|
|
90
|
-
default: O.none,
|
|
91
|
-
},
|
|
92
|
-
name: {
|
|
56
|
+
}),
|
|
57
|
+
name: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
93
58
|
title: O.none,
|
|
94
59
|
type: O.some('string'),
|
|
95
|
-
properties: O.none,
|
|
96
|
-
required: O.none,
|
|
97
60
|
additionalProperties: O.some(false),
|
|
98
|
-
|
|
99
|
-
anyOf: O.none,
|
|
100
|
-
oneOf: O.none,
|
|
101
|
-
not: O.none,
|
|
102
|
-
in: O.none,
|
|
103
|
-
default: O.none,
|
|
104
|
-
},
|
|
61
|
+
}),
|
|
105
62
|
}),
|
|
106
63
|
required: O.some(['id']),
|
|
107
64
|
additionalProperties: O.some(false),
|
|
108
|
-
|
|
109
|
-
anyOf: O.none,
|
|
110
|
-
oneOf: O.none,
|
|
111
|
-
not: O.none,
|
|
112
|
-
in: O.none,
|
|
113
|
-
default: O.none,
|
|
114
|
-
},
|
|
65
|
+
}),
|
|
115
66
|
};
|
|
116
67
|
const result = (0, GenerateHandlerTest_1.generateHandlerTest)(input);
|
|
117
68
|
if (E.isLeft(result)) {
|
|
@@ -146,46 +97,19 @@ describe('GenerateHandlerTest', () => {
|
|
|
146
97
|
it('should generate a handler test with empty inputs', () => {
|
|
147
98
|
const input = {
|
|
148
99
|
operationNameCamelCase: 'getItem',
|
|
149
|
-
input: {
|
|
150
|
-
|
|
151
|
-
type: O.none,
|
|
152
|
-
properties: O.none,
|
|
153
|
-
required: O.none,
|
|
154
|
-
additionalProperties: O.none,
|
|
155
|
-
allOf: O.none,
|
|
156
|
-
anyOf: O.none,
|
|
157
|
-
oneOf: O.none,
|
|
158
|
-
not: O.none,
|
|
159
|
-
in: O.none,
|
|
160
|
-
default: O.none,
|
|
161
|
-
},
|
|
162
|
-
output: {
|
|
100
|
+
input: (0, SchemaGenerator_1.generateNonArraySchemaObject)({}),
|
|
101
|
+
output: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
163
102
|
type: O.some('object'),
|
|
164
|
-
title: O.none,
|
|
165
103
|
properties: O.some({
|
|
166
|
-
success: {
|
|
104
|
+
success: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
167
105
|
title: O.none,
|
|
168
106
|
type: O.some('boolean'),
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
additionalProperties: O.none,
|
|
172
|
-
allOf: O.none,
|
|
173
|
-
anyOf: O.none,
|
|
174
|
-
oneOf: O.none,
|
|
175
|
-
not: O.none,
|
|
176
|
-
in: O.none,
|
|
177
|
-
default: O.none,
|
|
178
|
-
},
|
|
107
|
+
additionalProperties: O.some(false),
|
|
108
|
+
}),
|
|
179
109
|
}),
|
|
180
110
|
required: O.some(['success']),
|
|
181
111
|
additionalProperties: O.some(false),
|
|
182
|
-
|
|
183
|
-
anyOf: O.none,
|
|
184
|
-
oneOf: O.none,
|
|
185
|
-
not: O.none,
|
|
186
|
-
in: O.none,
|
|
187
|
-
default: O.none,
|
|
188
|
-
},
|
|
112
|
+
}),
|
|
189
113
|
};
|
|
190
114
|
const result = (0, GenerateHandlerTest_1.generateHandlerTest)(input);
|
|
191
115
|
if (E.isLeft(result)) {
|
|
@@ -219,101 +143,45 @@ describe('GenerateHandlerTest', () => {
|
|
|
219
143
|
it('should generate a handler test with a basic object input and output type', () => {
|
|
220
144
|
const input = {
|
|
221
145
|
operationNameCamelCase: 'createPerson',
|
|
222
|
-
input: {
|
|
223
|
-
title: O.none,
|
|
146
|
+
input: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
224
147
|
type: O.some('object'),
|
|
225
148
|
properties: O.some({
|
|
226
|
-
metadata: {
|
|
227
|
-
title: O.none,
|
|
149
|
+
metadata: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
228
150
|
type: O.some('object'),
|
|
229
151
|
properties: O.some({
|
|
230
|
-
name: {
|
|
152
|
+
name: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
231
153
|
title: O.none,
|
|
232
154
|
type: O.some('string'),
|
|
233
|
-
properties: O.none,
|
|
234
|
-
required: O.none,
|
|
235
155
|
additionalProperties: O.some(false),
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
oneOf: O.none,
|
|
239
|
-
not: O.none,
|
|
240
|
-
in: O.none,
|
|
241
|
-
default: O.none,
|
|
242
|
-
},
|
|
243
|
-
age: {
|
|
156
|
+
}),
|
|
157
|
+
age: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
244
158
|
title: O.none,
|
|
245
159
|
type: O.some('integer'),
|
|
246
|
-
properties: O.none,
|
|
247
|
-
required: O.none,
|
|
248
160
|
additionalProperties: O.some(false),
|
|
249
|
-
|
|
250
|
-
anyOf: O.none,
|
|
251
|
-
oneOf: O.none,
|
|
252
|
-
not: O.none,
|
|
253
|
-
in: O.none,
|
|
254
|
-
default: O.none,
|
|
255
|
-
},
|
|
161
|
+
}),
|
|
256
162
|
}),
|
|
257
|
-
required: O.none,
|
|
258
163
|
additionalProperties: O.some(false),
|
|
259
|
-
|
|
260
|
-
anyOf: O.none,
|
|
261
|
-
oneOf: O.none,
|
|
262
|
-
not: O.none,
|
|
263
|
-
in: O.none,
|
|
264
|
-
default: O.none,
|
|
265
|
-
},
|
|
164
|
+
}),
|
|
266
165
|
}),
|
|
267
|
-
required: O.none,
|
|
268
166
|
additionalProperties: O.some(false),
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
oneOf: O.none,
|
|
272
|
-
not: O.none,
|
|
273
|
-
in: O.none,
|
|
274
|
-
default: O.none,
|
|
275
|
-
},
|
|
276
|
-
output: {
|
|
277
|
-
title: O.none,
|
|
167
|
+
}),
|
|
168
|
+
output: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
278
169
|
type: O.some('object'),
|
|
279
170
|
properties: O.some({
|
|
280
|
-
parents: {
|
|
281
|
-
title: O.none,
|
|
171
|
+
parents: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
282
172
|
type: O.some('object'),
|
|
283
173
|
properties: O.some({
|
|
284
|
-
child: {
|
|
174
|
+
child: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
285
175
|
title: O.none,
|
|
286
176
|
type: O.some('string'),
|
|
287
|
-
properties: O.none,
|
|
288
|
-
required: O.none,
|
|
289
177
|
additionalProperties: O.some(false),
|
|
290
|
-
|
|
291
|
-
anyOf: O.none,
|
|
292
|
-
oneOf: O.none,
|
|
293
|
-
not: O.none,
|
|
294
|
-
in: O.none,
|
|
295
|
-
default: O.none,
|
|
296
|
-
},
|
|
178
|
+
}),
|
|
297
179
|
}),
|
|
298
|
-
required: O.none,
|
|
299
180
|
additionalProperties: O.some(false),
|
|
300
|
-
|
|
301
|
-
anyOf: O.none,
|
|
302
|
-
oneOf: O.none,
|
|
303
|
-
not: O.none,
|
|
304
|
-
in: O.none,
|
|
305
|
-
default: O.none,
|
|
306
|
-
},
|
|
181
|
+
}),
|
|
307
182
|
}),
|
|
308
|
-
required: O.none,
|
|
309
183
|
additionalProperties: O.some(false),
|
|
310
|
-
|
|
311
|
-
anyOf: O.none,
|
|
312
|
-
oneOf: O.none,
|
|
313
|
-
not: O.none,
|
|
314
|
-
in: O.none,
|
|
315
|
-
default: O.none,
|
|
316
|
-
},
|
|
184
|
+
}),
|
|
317
185
|
};
|
|
318
186
|
const result = (0, GenerateHandlerTest_1.generateHandlerTest)(input);
|
|
319
187
|
if (E.isLeft(result)) {
|
|
@@ -347,26 +215,17 @@ describe('GenerateHandlerTest', () => {
|
|
|
347
215
|
it('should generate a handler test with a basic array input and output type', () => {
|
|
348
216
|
const input = {
|
|
349
217
|
operationNameCamelCase: 'listItems',
|
|
350
|
-
input: {
|
|
218
|
+
input: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
351
219
|
type: O.some('object'),
|
|
352
|
-
title: O.none,
|
|
353
220
|
properties: O.some({
|
|
354
221
|
ids: {
|
|
355
222
|
title: O.none,
|
|
356
223
|
type: O.some('array'),
|
|
357
|
-
items: {
|
|
224
|
+
items: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
358
225
|
title: O.none,
|
|
359
226
|
type: O.some('integer'),
|
|
360
|
-
properties: O.none,
|
|
361
|
-
required: O.none,
|
|
362
227
|
additionalProperties: O.some(false),
|
|
363
|
-
|
|
364
|
-
anyOf: O.none,
|
|
365
|
-
oneOf: O.none,
|
|
366
|
-
not: O.none,
|
|
367
|
-
in: O.none,
|
|
368
|
-
default: O.none,
|
|
369
|
-
},
|
|
228
|
+
}),
|
|
370
229
|
properties: O.none,
|
|
371
230
|
required: O.none,
|
|
372
231
|
additionalProperties: O.some(false),
|
|
@@ -376,37 +235,23 @@ describe('GenerateHandlerTest', () => {
|
|
|
376
235
|
not: O.none,
|
|
377
236
|
in: O.none,
|
|
378
237
|
default: O.none,
|
|
238
|
+
nullable: O.none,
|
|
239
|
+
enum: O.none,
|
|
379
240
|
},
|
|
380
241
|
}),
|
|
381
|
-
required: O.none,
|
|
382
242
|
additionalProperties: O.some(false),
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
oneOf: O.none,
|
|
386
|
-
not: O.none,
|
|
387
|
-
in: O.none,
|
|
388
|
-
default: O.none,
|
|
389
|
-
},
|
|
390
|
-
output: {
|
|
243
|
+
}),
|
|
244
|
+
output: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
391
245
|
type: O.some('object'),
|
|
392
|
-
title: O.none,
|
|
393
246
|
properties: O.some({
|
|
394
247
|
parents: {
|
|
395
248
|
title: O.none,
|
|
396
249
|
type: O.some('array'),
|
|
397
|
-
items: {
|
|
250
|
+
items: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
398
251
|
title: O.none,
|
|
399
252
|
type: O.some('string'),
|
|
400
|
-
properties: O.none,
|
|
401
|
-
required: O.none,
|
|
402
253
|
additionalProperties: O.some(false),
|
|
403
|
-
|
|
404
|
-
anyOf: O.none,
|
|
405
|
-
oneOf: O.none,
|
|
406
|
-
not: O.none,
|
|
407
|
-
in: O.none,
|
|
408
|
-
default: O.none,
|
|
409
|
-
},
|
|
254
|
+
}),
|
|
410
255
|
properties: O.none,
|
|
411
256
|
required: O.none,
|
|
412
257
|
additionalProperties: O.some(false),
|
|
@@ -416,17 +261,12 @@ describe('GenerateHandlerTest', () => {
|
|
|
416
261
|
not: O.none,
|
|
417
262
|
in: O.none,
|
|
418
263
|
default: O.none,
|
|
264
|
+
nullable: O.none,
|
|
265
|
+
enum: O.none,
|
|
419
266
|
},
|
|
420
267
|
}),
|
|
421
|
-
required: O.none,
|
|
422
268
|
additionalProperties: O.some(false),
|
|
423
|
-
|
|
424
|
-
anyOf: O.none,
|
|
425
|
-
oneOf: O.none,
|
|
426
|
-
not: O.none,
|
|
427
|
-
in: O.none,
|
|
428
|
-
default: O.none,
|
|
429
|
-
},
|
|
269
|
+
}),
|
|
430
270
|
};
|
|
431
271
|
const result = (0, GenerateHandlerTest_1.generateHandlerTest)(input);
|
|
432
272
|
if (E.isLeft(result)) {
|
|
@@ -460,56 +300,27 @@ describe('GenerateHandlerTest', () => {
|
|
|
460
300
|
it('should generate a handler test with a complex object output type', () => {
|
|
461
301
|
const input = {
|
|
462
302
|
operationNameCamelCase: 'listItems',
|
|
463
|
-
input: {
|
|
464
|
-
title: O.none,
|
|
465
|
-
type: O.none,
|
|
466
|
-
properties: O.none,
|
|
467
|
-
required: O.none,
|
|
468
|
-
additionalProperties: O.none,
|
|
469
|
-
allOf: O.none,
|
|
470
|
-
anyOf: O.none,
|
|
471
|
-
oneOf: O.none,
|
|
472
|
-
not: O.none,
|
|
473
|
-
in: O.none,
|
|
474
|
-
default: O.none,
|
|
475
|
-
},
|
|
303
|
+
input: (0, SchemaGenerator_1.generateNonArraySchemaObject)({}),
|
|
476
304
|
output: {
|
|
477
305
|
type: O.some('object'),
|
|
478
306
|
title: O.none,
|
|
479
307
|
properties: O.some({
|
|
480
|
-
parents: {
|
|
481
|
-
title: O.none,
|
|
308
|
+
parents: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
482
309
|
type: O.some('object'),
|
|
483
310
|
properties: O.some({
|
|
484
|
-
child: {
|
|
311
|
+
child: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
485
312
|
title: O.none,
|
|
486
313
|
type: O.some('string'),
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
additionalProperties: O.none,
|
|
490
|
-
allOf: O.none,
|
|
491
|
-
anyOf: O.none,
|
|
492
|
-
oneOf: O.none,
|
|
493
|
-
not: O.none,
|
|
494
|
-
in: O.none,
|
|
495
|
-
default: O.none,
|
|
496
|
-
},
|
|
314
|
+
additionalProperties: O.some(false),
|
|
315
|
+
}),
|
|
497
316
|
valueList: {
|
|
498
317
|
title: O.none,
|
|
499
318
|
type: O.some('array'),
|
|
500
|
-
items: {
|
|
319
|
+
items: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
501
320
|
title: O.none,
|
|
502
321
|
type: O.some('string'),
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
additionalProperties: O.none,
|
|
506
|
-
allOf: O.none,
|
|
507
|
-
anyOf: O.none,
|
|
508
|
-
oneOf: O.none,
|
|
509
|
-
not: O.none,
|
|
510
|
-
in: O.none,
|
|
511
|
-
default: O.none,
|
|
512
|
-
},
|
|
322
|
+
additionalProperties: O.some(false),
|
|
323
|
+
}),
|
|
513
324
|
properties: O.none,
|
|
514
325
|
required: O.none,
|
|
515
326
|
additionalProperties: O.some(false),
|
|
@@ -519,17 +330,12 @@ describe('GenerateHandlerTest', () => {
|
|
|
519
330
|
not: O.none,
|
|
520
331
|
in: O.none,
|
|
521
332
|
default: O.none,
|
|
333
|
+
nullable: O.none,
|
|
334
|
+
enum: O.none,
|
|
522
335
|
},
|
|
523
336
|
}),
|
|
524
|
-
required: O.none,
|
|
525
337
|
additionalProperties: O.some(false),
|
|
526
|
-
|
|
527
|
-
anyOf: O.none,
|
|
528
|
-
oneOf: O.none,
|
|
529
|
-
not: O.none,
|
|
530
|
-
in: O.none,
|
|
531
|
-
default: O.none,
|
|
532
|
-
},
|
|
338
|
+
}),
|
|
533
339
|
}),
|
|
534
340
|
required: O.none,
|
|
535
341
|
additionalProperties: O.some(false),
|
|
@@ -539,6 +345,8 @@ describe('GenerateHandlerTest', () => {
|
|
|
539
345
|
not: O.none,
|
|
540
346
|
in: O.none,
|
|
541
347
|
default: O.none,
|
|
348
|
+
nullable: O.none,
|
|
349
|
+
enum: O.none,
|
|
542
350
|
},
|
|
543
351
|
};
|
|
544
352
|
const result = (0, GenerateHandlerTest_1.generateHandlerTest)(input);
|
|
@@ -573,53 +381,23 @@ describe('GenerateHandlerTest', () => {
|
|
|
573
381
|
it('should generate a handler test with a complex array output type', () => {
|
|
574
382
|
const input = {
|
|
575
383
|
operationNameCamelCase: 'listItems',
|
|
576
|
-
input: {
|
|
577
|
-
|
|
578
|
-
type: O.none,
|
|
579
|
-
properties: O.none,
|
|
580
|
-
required: O.none,
|
|
581
|
-
additionalProperties: O.none,
|
|
582
|
-
allOf: O.none,
|
|
583
|
-
anyOf: O.none,
|
|
584
|
-
oneOf: O.none,
|
|
585
|
-
not: O.none,
|
|
586
|
-
in: O.none,
|
|
587
|
-
default: O.none,
|
|
588
|
-
},
|
|
589
|
-
output: {
|
|
590
|
-
title: O.none,
|
|
384
|
+
input: (0, SchemaGenerator_1.generateNonArraySchemaObject)({}),
|
|
385
|
+
output: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
591
386
|
type: O.some('object'),
|
|
592
387
|
properties: O.some({
|
|
593
388
|
parents: {
|
|
594
389
|
title: O.none,
|
|
595
390
|
type: O.some('array'),
|
|
596
|
-
items: {
|
|
597
|
-
title: O.none,
|
|
391
|
+
items: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
598
392
|
type: O.some('object'),
|
|
599
393
|
properties: O.some({
|
|
600
|
-
child: {
|
|
394
|
+
child: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
601
395
|
title: O.none,
|
|
602
396
|
type: O.some('string'),
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
additionalProperties: O.none,
|
|
606
|
-
allOf: O.none,
|
|
607
|
-
anyOf: O.none,
|
|
608
|
-
oneOf: O.none,
|
|
609
|
-
not: O.none,
|
|
610
|
-
in: O.none,
|
|
611
|
-
default: O.none,
|
|
612
|
-
},
|
|
397
|
+
additionalProperties: O.some(false),
|
|
398
|
+
}),
|
|
613
399
|
}),
|
|
614
|
-
|
|
615
|
-
additionalProperties: O.none,
|
|
616
|
-
allOf: O.none,
|
|
617
|
-
anyOf: O.none,
|
|
618
|
-
oneOf: O.none,
|
|
619
|
-
not: O.none,
|
|
620
|
-
in: O.none,
|
|
621
|
-
default: O.none,
|
|
622
|
-
},
|
|
400
|
+
}),
|
|
623
401
|
properties: O.none,
|
|
624
402
|
required: O.none,
|
|
625
403
|
additionalProperties: O.some(false),
|
|
@@ -629,17 +407,12 @@ describe('GenerateHandlerTest', () => {
|
|
|
629
407
|
not: O.none,
|
|
630
408
|
in: O.none,
|
|
631
409
|
default: O.none,
|
|
410
|
+
nullable: O.none,
|
|
411
|
+
enum: O.none,
|
|
632
412
|
},
|
|
633
413
|
}),
|
|
634
|
-
required: O.none,
|
|
635
414
|
additionalProperties: O.some(false),
|
|
636
|
-
|
|
637
|
-
anyOf: O.none,
|
|
638
|
-
oneOf: O.none,
|
|
639
|
-
not: O.none,
|
|
640
|
-
in: O.none,
|
|
641
|
-
default: O.none,
|
|
642
|
-
},
|
|
415
|
+
}),
|
|
643
416
|
};
|
|
644
417
|
const result = (0, GenerateHandlerTest_1.generateHandlerTest)(input);
|
|
645
418
|
if (E.isLeft(result)) {
|
|
@@ -670,4 +443,157 @@ describe('GenerateHandlerTest', () => {
|
|
|
670
443
|
.nothingAfterAll()
|
|
671
444
|
);`.replace(/\s/g, '')).toEqual(result.right.replace(/\s/g, ''));
|
|
672
445
|
});
|
|
446
|
+
it('should generate a handler test with a enum value as test input', () => {
|
|
447
|
+
const input = {
|
|
448
|
+
operationNameCamelCase: 'listItems',
|
|
449
|
+
input: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
450
|
+
type: O.some('object'),
|
|
451
|
+
properties: O.some({
|
|
452
|
+
parents: {
|
|
453
|
+
title: O.none,
|
|
454
|
+
type: O.some('array'),
|
|
455
|
+
items: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
456
|
+
type: O.some('object'),
|
|
457
|
+
title: O.some('Code interpreter tool'),
|
|
458
|
+
properties: O.some({
|
|
459
|
+
type: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
460
|
+
title: O.none,
|
|
461
|
+
type: O.some('string'),
|
|
462
|
+
enum: O.some(['code_interpreter']),
|
|
463
|
+
}),
|
|
464
|
+
}),
|
|
465
|
+
required: O.some(['type']),
|
|
466
|
+
}),
|
|
467
|
+
properties: O.none,
|
|
468
|
+
required: O.none,
|
|
469
|
+
additionalProperties: O.some(false),
|
|
470
|
+
allOf: O.none,
|
|
471
|
+
anyOf: O.none,
|
|
472
|
+
oneOf: O.none,
|
|
473
|
+
not: O.none,
|
|
474
|
+
in: O.none,
|
|
475
|
+
default: O.none,
|
|
476
|
+
nullable: O.none,
|
|
477
|
+
enum: O.none,
|
|
478
|
+
},
|
|
479
|
+
}),
|
|
480
|
+
additionalProperties: O.some(false),
|
|
481
|
+
}),
|
|
482
|
+
output: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
483
|
+
type: O.some('object'),
|
|
484
|
+
properties: O.some({
|
|
485
|
+
success: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
486
|
+
title: O.none,
|
|
487
|
+
type: O.some('boolean'),
|
|
488
|
+
additionalProperties: O.some(false),
|
|
489
|
+
}),
|
|
490
|
+
}),
|
|
491
|
+
required: O.some(['success']),
|
|
492
|
+
additionalProperties: O.some(false),
|
|
493
|
+
}),
|
|
494
|
+
};
|
|
495
|
+
const result = (0, GenerateHandlerTest_1.generateHandlerTest)(input);
|
|
496
|
+
if (E.isLeft(result)) {
|
|
497
|
+
console.log(result.left);
|
|
498
|
+
throw new Error('Expected right');
|
|
499
|
+
}
|
|
500
|
+
expect(`import { OperationHandlerTestSetup } from '@trayio/cdk-dsl/connector/operation/OperationHandlerTest';
|
|
501
|
+
import { OperationHandlerResult } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
502
|
+
import { listItemsHandler } from './handler';
|
|
503
|
+
import '@trayio/cdk-runtime/connector/operation/OperationHandlerTestRunner';
|
|
504
|
+
|
|
505
|
+
OperationHandlerTestSetup.configureHandlerTest(listItemsHandler, (handlerTest) =>
|
|
506
|
+
handlerTest
|
|
507
|
+
.usingHandlerContext('test')
|
|
508
|
+
.nothingBeforeAll()
|
|
509
|
+
.testCase('should ${input.operationNameCamelCase}', (testCase) =>
|
|
510
|
+
testCase
|
|
511
|
+
.givenNothing()
|
|
512
|
+
.when(() => ({'parents':[{'type':'code_interpreter'}]}))
|
|
513
|
+
.then(({ output }) => {
|
|
514
|
+
// console.log(output);
|
|
515
|
+
const outputValue =
|
|
516
|
+
OperationHandlerResult.getSuccessfulValueOrFail(output);
|
|
517
|
+
expect(outputValue['success']).toEqual(true);
|
|
518
|
+
})
|
|
519
|
+
.finallyDoNothing()
|
|
520
|
+
)
|
|
521
|
+
.nothingAfterAll()
|
|
522
|
+
);`.replace(/\s/g, '')).toEqual(result.right.replace(/\s/g, ''));
|
|
523
|
+
});
|
|
524
|
+
it('should generate a handler test with a anyOf schema value as test input', () => {
|
|
525
|
+
const input = {
|
|
526
|
+
operationNameCamelCase: 'listItems',
|
|
527
|
+
input: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
528
|
+
type: O.some('object'),
|
|
529
|
+
properties: O.some({
|
|
530
|
+
parents: {
|
|
531
|
+
title: O.none,
|
|
532
|
+
type: O.some('array'),
|
|
533
|
+
items: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
534
|
+
oneOf: O.some([
|
|
535
|
+
(0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
536
|
+
type: O.some('string'),
|
|
537
|
+
default: O.some('generated'),
|
|
538
|
+
}),
|
|
539
|
+
(0, SchemaGenerator_1.generateNonArraySchemaObject)({ type: O.some('integer') }),
|
|
540
|
+
]),
|
|
541
|
+
}),
|
|
542
|
+
properties: O.none,
|
|
543
|
+
required: O.none,
|
|
544
|
+
additionalProperties: O.some(false),
|
|
545
|
+
allOf: O.none,
|
|
546
|
+
anyOf: O.none,
|
|
547
|
+
oneOf: O.none,
|
|
548
|
+
not: O.none,
|
|
549
|
+
in: O.none,
|
|
550
|
+
default: O.none,
|
|
551
|
+
nullable: O.none,
|
|
552
|
+
enum: O.none,
|
|
553
|
+
},
|
|
554
|
+
}),
|
|
555
|
+
additionalProperties: O.some(false),
|
|
556
|
+
}),
|
|
557
|
+
output: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
558
|
+
type: O.some('object'),
|
|
559
|
+
properties: O.some({
|
|
560
|
+
success: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
561
|
+
title: O.none,
|
|
562
|
+
type: O.some('boolean'),
|
|
563
|
+
additionalProperties: O.some(false),
|
|
564
|
+
}),
|
|
565
|
+
}),
|
|
566
|
+
required: O.some(['success']),
|
|
567
|
+
additionalProperties: O.some(false),
|
|
568
|
+
}),
|
|
569
|
+
};
|
|
570
|
+
const result = (0, GenerateHandlerTest_1.generateHandlerTest)(input);
|
|
571
|
+
if (E.isLeft(result)) {
|
|
572
|
+
console.log(result.left);
|
|
573
|
+
throw new Error('Expected right');
|
|
574
|
+
}
|
|
575
|
+
expect(`import { OperationHandlerTestSetup } from '@trayio/cdk-dsl/connector/operation/OperationHandlerTest';
|
|
576
|
+
import { OperationHandlerResult } from '@trayio/cdk-dsl/connector/operation/OperationHandler';
|
|
577
|
+
import { listItemsHandler } from './handler';
|
|
578
|
+
import '@trayio/cdk-runtime/connector/operation/OperationHandlerTestRunner';
|
|
579
|
+
|
|
580
|
+
OperationHandlerTestSetup.configureHandlerTest(listItemsHandler, (handlerTest) =>
|
|
581
|
+
handlerTest
|
|
582
|
+
.usingHandlerContext('test')
|
|
583
|
+
.nothingBeforeAll()
|
|
584
|
+
.testCase('should ${input.operationNameCamelCase}', (testCase) =>
|
|
585
|
+
testCase
|
|
586
|
+
.givenNothing()
|
|
587
|
+
.when(() => ({'parents':['generated']}))
|
|
588
|
+
.then(({ output }) => {
|
|
589
|
+
// console.log(output);
|
|
590
|
+
const outputValue =
|
|
591
|
+
OperationHandlerResult.getSuccessfulValueOrFail(output);
|
|
592
|
+
expect(outputValue['success']).toEqual(true);
|
|
593
|
+
})
|
|
594
|
+
.finallyDoNothing()
|
|
595
|
+
)
|
|
596
|
+
.nothingAfterAll()
|
|
597
|
+
);`.replace(/\s/g, '')).toEqual(result.right.replace(/\s/g, ''));
|
|
598
|
+
});
|
|
673
599
|
});
|