@trayio/tray-openapi 2.11.1 → 2.12.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/README.md +39 -0
- package/dist/OpenApiSchemaImporter.js +1 -1
- package/dist/OpenApiTypeDescriptors.d.ts +1 -0
- package/dist/OpenApiTypeDescriptors.d.ts.map +1 -1
- package/dist/OpenApiTypeDescriptors.js +1 -0
- package/dist/file-generators/GenerateHandler.test.js +18 -0
- package/dist/file-generators/GenerateHandlerTest.test.js +33 -0
- package/dist/file-generators/types/GenerateInputSchema.d.ts.map +1 -1
- package/dist/file-generators/types/GenerateInputSchema.js +3 -0
- package/dist/file-generators/types/GenerateInputSchema.test.js +9 -0
- package/dist/file-generators/types/GenerateInputType.test.js +22 -0
- package/dist/file-generators/types/GenerateInputTypes.d.ts.map +1 -1
- package/dist/file-generators/types/GenerateInputTypes.js +4 -0
- package/dist/file-generators/types/GenerateOutput.d.ts.map +1 -1
- package/dist/file-generators/types/GenerateOutput.js +4 -0
- package/dist/file-generators/types/GenerateOutput.test.js +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
This module speeds up the development process of creating a new Tray CDK connector by parsing an OpenAPI specification file for a given API and generating operation handlers, meta data, input and output types.
|
|
2
|
+
|
|
3
|
+
This beta functionality is available from the @trayio/cdk-cli module via the `tray-cdk import-openapi-spec` command. If you encounter any issues that you wish the team to investigate further please supply us with OpenApi specification you are importing and the `errors.json` that has been generated during the import process.
|
|
4
|
+
|
|
5
|
+
These are the features that are currently supported/unsupported:
|
|
6
|
+
- OpenAPI spec interpretation:
|
|
7
|
+
- Supported:
|
|
8
|
+
- schema internal component references
|
|
9
|
+
- JSON OpenAPI specification version 3
|
|
10
|
+
- If your version is older you can use this to update it: [Swagger Editor](https://editor.swagger.io/) (From the top menu bar, select edit, convert to Open API 3, you can also use this to convert from YAML to JSON)
|
|
11
|
+
- Unsupported:
|
|
12
|
+
- Swagger API version 2
|
|
13
|
+
- YAML spec files
|
|
14
|
+
- open API specs with multiple server URLs, manually edit the file to set your desired server to the first in the array
|
|
15
|
+
- recursive schema references
|
|
16
|
+
- external schema references
|
|
17
|
+
- schema references that target nested components
|
|
18
|
+
- Authentication
|
|
19
|
+
- Unsupported:
|
|
20
|
+
- generation of Auth type
|
|
21
|
+
- handlers utilising the auth token in handlers
|
|
22
|
+
- Input/output types:
|
|
23
|
+
- Supported:
|
|
24
|
+
- Primitive types: number, string, boolean
|
|
25
|
+
- Objects
|
|
26
|
+
- 2XX response schemas
|
|
27
|
+
- Empty input/output
|
|
28
|
+
- Unsupported:
|
|
29
|
+
- enum types
|
|
30
|
+
- array types
|
|
31
|
+
- non 2XX response schemas
|
|
32
|
+
- Request/Response types:
|
|
33
|
+
- Supported:
|
|
34
|
+
- Json request/response
|
|
35
|
+
- Unsupported:
|
|
36
|
+
- xml request/response
|
|
37
|
+
- text request/response
|
|
38
|
+
- file request/response
|
|
39
|
+
- form request/response
|
|
@@ -33,8 +33,8 @@ const Apply_1 = require("fp-ts/Apply");
|
|
|
33
33
|
const json_ref_resolver_1 = require("@stoplight/json-ref-resolver");
|
|
34
34
|
const StringExtensions_1 = require("@trayio/commons/string/StringExtensions");
|
|
35
35
|
const lodash_1 = require("lodash");
|
|
36
|
-
const stream_1 = require("stream");
|
|
37
36
|
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions");
|
|
37
|
+
const stream_1 = require("stream");
|
|
38
38
|
const OpenApiCodecs_1 = require("./OpenApiCodecs");
|
|
39
39
|
const GenerateHandler_1 = require("./file-generators/GenerateHandler");
|
|
40
40
|
const GenerateOutput_1 = require("./file-generators/types/GenerateOutput");
|
|
@@ -89,6 +89,7 @@ export interface NonArraySchemaObject extends BaseSchemaObject {
|
|
|
89
89
|
type: O.Option<NonArraySchemaObjectType>;
|
|
90
90
|
}
|
|
91
91
|
export type BaseSchemaObject = {
|
|
92
|
+
title: O.Option<string>;
|
|
92
93
|
additionalProperties: O.Option<boolean | SchemaObject>;
|
|
93
94
|
properties: O.Option<Record<string, SchemaObject>>;
|
|
94
95
|
required: O.Option<string[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiTypeDescriptors.d.ts","sourceRoot":"","sources":["../src/OpenApiTypeDescriptors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,MAAM,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE;QAAE,MAAM,EAAE,iBAAiB,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,EAAE,CAAC;CACvD,CAAC;AAEF,MAAM,MAAM,MAAM,GAAG;IACpB,GAAG,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;KACpB,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC/C,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC3B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,aAAa,GAAG;IAC5C,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG;IAC9C,GAAG,EAAE,SAAS,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,cAAc,GAAG,gBAAgB,C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MAAM,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC;IACvD,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC;IACnD,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC,CAAC;IAChC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;IAC5B,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;CACrB,CAAC;AAYF,eAAO,MAAM,oCAAoC,EAAE,CAAC,CAAC,IAAI,CACxD,gBAAgB,EAChB,OAAO,CAiBP,CAAC;AAyBF,eAAO,MAAM,0BAA0B,EAAE,CAAC,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAMnE,CAAC;AAEH,eAAO,MAAM,qBAAqB,wDAEjC,CAAC;AAuBF,eAAO,MAAM,6BAA6B,EAAE,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAQpE,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAO9D,CAAC;AAUH,eAAO,MAAM,yBAAyB,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAWpE,CAAC"}
|
|
@@ -36,6 +36,7 @@ const nonArraySchemaObjectType = t.keyof({
|
|
|
36
36
|
integer: null,
|
|
37
37
|
});
|
|
38
38
|
exports.baseSchemaObjectSchemaTypeDescriptor = t.recursion('baseSchema', () => t.type({
|
|
39
|
+
title: (0, io_ts_types_1.optionFromNullable)(t.string),
|
|
39
40
|
additionalProperties: (0, io_ts_types_1.optionFromNullable)(t.union([t.boolean, exports.schemaObjectTypeDescriptor])),
|
|
40
41
|
properties: (0, io_ts_types_1.optionFromNullable)(t.record(t.string, exports.schemaObjectTypeDescriptor)),
|
|
41
42
|
required: (0, io_ts_types_1.optionFromNullable)(t.array(t.string)),
|
|
@@ -27,6 +27,7 @@ const E = __importStar(require("fp-ts/Either"));
|
|
|
27
27
|
const O = __importStar(require("fp-ts/Option"));
|
|
28
28
|
const GenerateHandler_1 = require("./GenerateHandler");
|
|
29
29
|
const getGenerateHandlerInput = (input) => (Object.assign({ connectorNamePascalCase: 'OpenApiTest', operationNamePascalCase: 'GetPhoto', operationNameCamelCase: 'getPhoto', httpMethod: 'get', baseUrl: 'https://jsonplaceholder.typicode.com', input: {
|
|
30
|
+
title: O.none,
|
|
30
31
|
properties: O.none,
|
|
31
32
|
additionalProperties: O.none,
|
|
32
33
|
required: O.none,
|
|
@@ -62,8 +63,10 @@ describe('GenerateHandler', () => {
|
|
|
62
63
|
it('it should generate a handler with a path parameter', () => {
|
|
63
64
|
const input = {
|
|
64
65
|
type: O.some('object'),
|
|
66
|
+
title: O.none,
|
|
65
67
|
properties: O.some({
|
|
66
68
|
photoId: {
|
|
69
|
+
title: O.none,
|
|
67
70
|
type: O.some('string'),
|
|
68
71
|
in: O.some('path'),
|
|
69
72
|
properties: O.none,
|
|
@@ -109,8 +112,10 @@ describe('GenerateHandler', () => {
|
|
|
109
112
|
it('it should generate a handler with a body input as json', () => {
|
|
110
113
|
const input = {
|
|
111
114
|
type: O.some('object'),
|
|
115
|
+
title: O.none,
|
|
112
116
|
properties: O.some({
|
|
113
117
|
photoId: {
|
|
118
|
+
title: O.none,
|
|
114
119
|
type: O.some('string'),
|
|
115
120
|
in: O.some('body'),
|
|
116
121
|
properties: O.none,
|
|
@@ -153,8 +158,10 @@ describe('GenerateHandler', () => {
|
|
|
153
158
|
it('it should generate a handler with a query string input', () => {
|
|
154
159
|
const input = {
|
|
155
160
|
type: O.some('object'),
|
|
161
|
+
title: O.none,
|
|
156
162
|
properties: O.some({
|
|
157
163
|
id: {
|
|
164
|
+
title: O.none,
|
|
158
165
|
type: O.some('string'),
|
|
159
166
|
in: O.some('query'),
|
|
160
167
|
properties: O.none,
|
|
@@ -197,8 +204,10 @@ describe('GenerateHandler', () => {
|
|
|
197
204
|
it('it should generate a handler with a header input', () => {
|
|
198
205
|
const input = {
|
|
199
206
|
type: O.some('object'),
|
|
207
|
+
title: O.none,
|
|
200
208
|
properties: O.some({
|
|
201
209
|
'Content-Type': {
|
|
210
|
+
title: O.none,
|
|
202
211
|
type: O.some('string'),
|
|
203
212
|
in: O.some('header'),
|
|
204
213
|
properties: O.none,
|
|
@@ -241,8 +250,10 @@ describe('GenerateHandler', () => {
|
|
|
241
250
|
it('it should generate a handler and transform number type to string for input', () => {
|
|
242
251
|
const input = {
|
|
243
252
|
type: O.some('object'),
|
|
253
|
+
title: O.none,
|
|
244
254
|
properties: O.some({
|
|
245
255
|
'Content-Type': {
|
|
256
|
+
title: O.none,
|
|
246
257
|
type: O.some('integer'),
|
|
247
258
|
in: O.some('header'),
|
|
248
259
|
properties: O.none,
|
|
@@ -285,8 +296,10 @@ describe('GenerateHandler', () => {
|
|
|
285
296
|
it('it should generate a handler with a query string and path param input', () => {
|
|
286
297
|
const input = {
|
|
287
298
|
type: O.some('object'),
|
|
299
|
+
title: O.none,
|
|
288
300
|
properties: O.some({
|
|
289
301
|
id: {
|
|
302
|
+
title: O.none,
|
|
290
303
|
type: O.some('string'),
|
|
291
304
|
in: O.some('query'),
|
|
292
305
|
properties: O.none,
|
|
@@ -298,6 +311,7 @@ describe('GenerateHandler', () => {
|
|
|
298
311
|
not: O.none,
|
|
299
312
|
},
|
|
300
313
|
photoId: {
|
|
314
|
+
title: O.none,
|
|
301
315
|
type: O.some('string'),
|
|
302
316
|
in: O.some('path'),
|
|
303
317
|
properties: O.none,
|
|
@@ -309,6 +323,7 @@ describe('GenerateHandler', () => {
|
|
|
309
323
|
not: O.none,
|
|
310
324
|
},
|
|
311
325
|
commentId: {
|
|
326
|
+
title: O.none,
|
|
312
327
|
type: O.some('string'),
|
|
313
328
|
in: O.some('path'),
|
|
314
329
|
properties: O.none,
|
|
@@ -354,8 +369,10 @@ describe('GenerateHandler', () => {
|
|
|
354
369
|
it('it should generate a handler with a query string and body param input', () => {
|
|
355
370
|
const input = {
|
|
356
371
|
type: O.some('object'),
|
|
372
|
+
title: O.none,
|
|
357
373
|
properties: O.some({
|
|
358
374
|
id: {
|
|
375
|
+
title: O.none,
|
|
359
376
|
type: O.some('string'),
|
|
360
377
|
in: O.some('query'),
|
|
361
378
|
properties: O.none,
|
|
@@ -367,6 +384,7 @@ describe('GenerateHandler', () => {
|
|
|
367
384
|
not: O.none,
|
|
368
385
|
},
|
|
369
386
|
photoId: {
|
|
387
|
+
title: O.none,
|
|
370
388
|
type: O.some('string'),
|
|
371
389
|
in: O.some('body'),
|
|
372
390
|
properties: O.none,
|
|
@@ -32,8 +32,10 @@ describe('GenerateHandlerTest', () => {
|
|
|
32
32
|
operationNameCamelCase: 'getItem',
|
|
33
33
|
input: {
|
|
34
34
|
type: O.some('object'),
|
|
35
|
+
title: O.none,
|
|
35
36
|
properties: O.some({
|
|
36
37
|
id: {
|
|
38
|
+
title: O.none,
|
|
37
39
|
type: O.some('integer'),
|
|
38
40
|
format: 'int64',
|
|
39
41
|
properties: O.none,
|
|
@@ -46,6 +48,7 @@ describe('GenerateHandlerTest', () => {
|
|
|
46
48
|
in: O.none,
|
|
47
49
|
},
|
|
48
50
|
name: {
|
|
51
|
+
title: O.none,
|
|
49
52
|
type: O.some('string'),
|
|
50
53
|
properties: O.none,
|
|
51
54
|
required: O.none,
|
|
@@ -67,8 +70,10 @@ describe('GenerateHandlerTest', () => {
|
|
|
67
70
|
},
|
|
68
71
|
output: {
|
|
69
72
|
type: O.some('object'),
|
|
73
|
+
title: O.none,
|
|
70
74
|
properties: O.some({
|
|
71
75
|
id: {
|
|
76
|
+
title: O.none,
|
|
72
77
|
type: O.some('integer'),
|
|
73
78
|
format: 'int64',
|
|
74
79
|
properties: O.none,
|
|
@@ -81,6 +86,7 @@ describe('GenerateHandlerTest', () => {
|
|
|
81
86
|
in: O.none,
|
|
82
87
|
},
|
|
83
88
|
name: {
|
|
89
|
+
title: O.none,
|
|
84
90
|
type: O.some('string'),
|
|
85
91
|
properties: O.none,
|
|
86
92
|
required: O.none,
|
|
@@ -135,6 +141,7 @@ describe('GenerateHandlerTest', () => {
|
|
|
135
141
|
const input = {
|
|
136
142
|
operationNameCamelCase: 'getItem',
|
|
137
143
|
input: {
|
|
144
|
+
title: O.none,
|
|
138
145
|
type: O.none,
|
|
139
146
|
properties: O.none,
|
|
140
147
|
required: O.none,
|
|
@@ -147,8 +154,10 @@ describe('GenerateHandlerTest', () => {
|
|
|
147
154
|
},
|
|
148
155
|
output: {
|
|
149
156
|
type: O.some('object'),
|
|
157
|
+
title: O.none,
|
|
150
158
|
properties: O.some({
|
|
151
159
|
success: {
|
|
160
|
+
title: O.none,
|
|
152
161
|
type: O.some('boolean'),
|
|
153
162
|
properties: O.none,
|
|
154
163
|
required: O.none,
|
|
@@ -202,12 +211,15 @@ describe('GenerateHandlerTest', () => {
|
|
|
202
211
|
const input = {
|
|
203
212
|
operationNameCamelCase: 'createPerson',
|
|
204
213
|
input: {
|
|
214
|
+
title: O.none,
|
|
205
215
|
type: O.some('object'),
|
|
206
216
|
properties: O.some({
|
|
207
217
|
metadata: {
|
|
218
|
+
title: O.none,
|
|
208
219
|
type: O.some('object'),
|
|
209
220
|
properties: O.some({
|
|
210
221
|
name: {
|
|
222
|
+
title: O.none,
|
|
211
223
|
type: O.some('string'),
|
|
212
224
|
properties: O.none,
|
|
213
225
|
required: O.none,
|
|
@@ -219,6 +231,7 @@ describe('GenerateHandlerTest', () => {
|
|
|
219
231
|
in: O.none,
|
|
220
232
|
},
|
|
221
233
|
age: {
|
|
234
|
+
title: O.none,
|
|
222
235
|
type: O.some('integer'),
|
|
223
236
|
properties: O.none,
|
|
224
237
|
required: O.none,
|
|
@@ -248,12 +261,15 @@ describe('GenerateHandlerTest', () => {
|
|
|
248
261
|
in: O.none,
|
|
249
262
|
},
|
|
250
263
|
output: {
|
|
264
|
+
title: O.none,
|
|
251
265
|
type: O.some('object'),
|
|
252
266
|
properties: O.some({
|
|
253
267
|
parents: {
|
|
268
|
+
title: O.none,
|
|
254
269
|
type: O.some('object'),
|
|
255
270
|
properties: O.some({
|
|
256
271
|
child: {
|
|
272
|
+
title: O.none,
|
|
257
273
|
type: O.some('string'),
|
|
258
274
|
properties: O.none,
|
|
259
275
|
required: O.none,
|
|
@@ -317,10 +333,13 @@ describe('GenerateHandlerTest', () => {
|
|
|
317
333
|
operationNameCamelCase: 'listItems',
|
|
318
334
|
input: {
|
|
319
335
|
type: O.some('object'),
|
|
336
|
+
title: O.none,
|
|
320
337
|
properties: O.some({
|
|
321
338
|
ids: {
|
|
339
|
+
title: O.none,
|
|
322
340
|
type: 'array',
|
|
323
341
|
items: {
|
|
342
|
+
title: O.none,
|
|
324
343
|
type: O.some('integer'),
|
|
325
344
|
properties: O.none,
|
|
326
345
|
required: O.none,
|
|
@@ -351,10 +370,13 @@ describe('GenerateHandlerTest', () => {
|
|
|
351
370
|
},
|
|
352
371
|
output: {
|
|
353
372
|
type: O.some('object'),
|
|
373
|
+
title: O.none,
|
|
354
374
|
properties: O.some({
|
|
355
375
|
parents: {
|
|
376
|
+
title: O.none,
|
|
356
377
|
type: 'array',
|
|
357
378
|
items: {
|
|
379
|
+
title: O.none,
|
|
358
380
|
type: O.some('string'),
|
|
359
381
|
properties: O.none,
|
|
360
382
|
required: O.none,
|
|
@@ -417,6 +439,7 @@ describe('GenerateHandlerTest', () => {
|
|
|
417
439
|
const input = {
|
|
418
440
|
operationNameCamelCase: 'listItems',
|
|
419
441
|
input: {
|
|
442
|
+
title: O.none,
|
|
420
443
|
type: O.none,
|
|
421
444
|
properties: O.none,
|
|
422
445
|
required: O.none,
|
|
@@ -429,11 +452,14 @@ describe('GenerateHandlerTest', () => {
|
|
|
429
452
|
},
|
|
430
453
|
output: {
|
|
431
454
|
type: O.some('object'),
|
|
455
|
+
title: O.none,
|
|
432
456
|
properties: O.some({
|
|
433
457
|
parents: {
|
|
458
|
+
title: O.none,
|
|
434
459
|
type: O.some('object'),
|
|
435
460
|
properties: O.some({
|
|
436
461
|
child: {
|
|
462
|
+
title: O.none,
|
|
437
463
|
type: O.some('string'),
|
|
438
464
|
properties: O.none,
|
|
439
465
|
required: O.none,
|
|
@@ -445,8 +471,10 @@ describe('GenerateHandlerTest', () => {
|
|
|
445
471
|
in: O.none,
|
|
446
472
|
},
|
|
447
473
|
valueList: {
|
|
474
|
+
title: O.none,
|
|
448
475
|
type: 'array',
|
|
449
476
|
items: {
|
|
477
|
+
title: O.none,
|
|
450
478
|
type: O.some('string'),
|
|
451
479
|
properties: O.none,
|
|
452
480
|
required: O.none,
|
|
@@ -518,6 +546,7 @@ describe('GenerateHandlerTest', () => {
|
|
|
518
546
|
const input = {
|
|
519
547
|
operationNameCamelCase: 'listItems',
|
|
520
548
|
input: {
|
|
549
|
+
title: O.none,
|
|
521
550
|
type: O.none,
|
|
522
551
|
properties: O.none,
|
|
523
552
|
required: O.none,
|
|
@@ -529,14 +558,18 @@ describe('GenerateHandlerTest', () => {
|
|
|
529
558
|
in: O.none,
|
|
530
559
|
},
|
|
531
560
|
output: {
|
|
561
|
+
title: O.none,
|
|
532
562
|
type: O.some('object'),
|
|
533
563
|
properties: O.some({
|
|
534
564
|
parents: {
|
|
565
|
+
title: O.none,
|
|
535
566
|
type: 'array',
|
|
536
567
|
items: {
|
|
568
|
+
title: O.none,
|
|
537
569
|
type: O.some('object'),
|
|
538
570
|
properties: O.some({
|
|
539
571
|
child: {
|
|
572
|
+
title: O.none,
|
|
540
573
|
type: O.some('string'),
|
|
541
574
|
properties: O.none,
|
|
542
575
|
required: O.none,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateInputSchema.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateInputSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAQlC,OAAO,EACN,IAAI,EAGJ,YAAY,EAEZ,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"GenerateInputSchema.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateInputSchema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAQlC,OAAO,EACN,IAAI,EAGJ,YAAY,EAEZ,MAAM,8BAA8B,CAAC;AA4ItC,eAAO,MAAM,mBAAmB,aACrB,IAAI,KACZ,EAAE,MAAM,CAAC,KAAK,EAAE,YAAY,CAiC9B,CAAC"}
|
|
@@ -42,6 +42,7 @@ const mergeRequired = (params, body) => {
|
|
|
42
42
|
return [];
|
|
43
43
|
};
|
|
44
44
|
const mergeParamsAndBody = (params, body) => ({
|
|
45
|
+
title: O.none,
|
|
45
46
|
type: O.some('object'),
|
|
46
47
|
properties: O.some(Object.assign(Object.assign({}, (O.isSome(body.properties) && body.properties.value)), (O.isSome(params.properties) && params.properties.value))),
|
|
47
48
|
required: O.some(mergeRequired(params, body)),
|
|
@@ -69,6 +70,7 @@ const transformInput = (parameters) => {
|
|
|
69
70
|
}
|
|
70
71
|
});
|
|
71
72
|
return {
|
|
73
|
+
title: O.none,
|
|
72
74
|
type: O.some('object'),
|
|
73
75
|
properties: O.some(transformedParameters),
|
|
74
76
|
required: O.some([...requiredParameters]),
|
|
@@ -88,6 +90,7 @@ const appendInPropertyToBody = (body) => O.fold(() => body, (properties) => {
|
|
|
88
90
|
return Object.assign(Object.assign({}, body), { properties: O.some(propsWithInBody) });
|
|
89
91
|
})(body.properties);
|
|
90
92
|
const blankOutputSchema = () => ({
|
|
93
|
+
title: O.none,
|
|
91
94
|
type: O.none,
|
|
92
95
|
properties: O.none,
|
|
93
96
|
required: O.none,
|
|
@@ -51,6 +51,7 @@ describe('GenerateInputSchema', () => {
|
|
|
51
51
|
description: 'The user id.',
|
|
52
52
|
schema: {
|
|
53
53
|
type: O.some('integer'),
|
|
54
|
+
title: O.none,
|
|
54
55
|
properties: O.none,
|
|
55
56
|
additionalProperties: O.some(false),
|
|
56
57
|
required: O.none,
|
|
@@ -69,6 +70,7 @@ describe('GenerateInputSchema', () => {
|
|
|
69
70
|
description: 'The date of the post.',
|
|
70
71
|
schema: {
|
|
71
72
|
type: O.some('string'),
|
|
73
|
+
title: O.none,
|
|
72
74
|
properties: O.none,
|
|
73
75
|
additionalProperties: O.some(false),
|
|
74
76
|
format: O.none,
|
|
@@ -117,10 +119,12 @@ describe('GenerateInputSchema', () => {
|
|
|
117
119
|
'application/json': {
|
|
118
120
|
schema: O.some({
|
|
119
121
|
type: O.some('object'),
|
|
122
|
+
title: O.some('Post'),
|
|
120
123
|
required: O.some(['id', 'userId', 'title', 'body']),
|
|
121
124
|
properties: O.some({
|
|
122
125
|
id: {
|
|
123
126
|
type: O.some('integer'),
|
|
127
|
+
title: O.none,
|
|
124
128
|
properties: O.none,
|
|
125
129
|
additionalProperties: O.some(false),
|
|
126
130
|
required: O.none,
|
|
@@ -132,6 +136,7 @@ describe('GenerateInputSchema', () => {
|
|
|
132
136
|
},
|
|
133
137
|
userId: {
|
|
134
138
|
type: O.some('integer'),
|
|
139
|
+
title: O.none,
|
|
135
140
|
properties: O.none,
|
|
136
141
|
additionalProperties: O.some(false),
|
|
137
142
|
required: O.none,
|
|
@@ -143,6 +148,7 @@ describe('GenerateInputSchema', () => {
|
|
|
143
148
|
},
|
|
144
149
|
title: {
|
|
145
150
|
type: O.some('string'),
|
|
151
|
+
title: O.none,
|
|
146
152
|
properties: O.none,
|
|
147
153
|
additionalProperties: O.some(false),
|
|
148
154
|
required: O.none,
|
|
@@ -154,6 +160,7 @@ describe('GenerateInputSchema', () => {
|
|
|
154
160
|
},
|
|
155
161
|
body: {
|
|
156
162
|
type: O.some('string'),
|
|
163
|
+
title: O.none,
|
|
157
164
|
properties: O.none,
|
|
158
165
|
additionalProperties: O.some(false),
|
|
159
166
|
required: O.none,
|
|
@@ -204,10 +211,12 @@ describe('GenerateInputSchema', () => {
|
|
|
204
211
|
required: O.some(true),
|
|
205
212
|
description: 'tags to filter by.',
|
|
206
213
|
schema: {
|
|
214
|
+
title: O.none,
|
|
207
215
|
type: 'array',
|
|
208
216
|
format: O.none,
|
|
209
217
|
items: {
|
|
210
218
|
type: O.some('string'),
|
|
219
|
+
title: O.none,
|
|
211
220
|
properties: O.none,
|
|
212
221
|
additionalProperties: O.some(false),
|
|
213
222
|
required: O.none,
|
|
@@ -48,10 +48,12 @@ describe('GenerateInputType', () => {
|
|
|
48
48
|
content: {
|
|
49
49
|
'application/json': {
|
|
50
50
|
schema: O.some({
|
|
51
|
+
title: O.none,
|
|
51
52
|
type: O.some('object'),
|
|
52
53
|
required: O.some(['id', 'userId', 'title', 'body']),
|
|
53
54
|
properties: O.some({
|
|
54
55
|
id: {
|
|
56
|
+
title: O.none,
|
|
55
57
|
type: O.some('integer'),
|
|
56
58
|
properties: O.none,
|
|
57
59
|
additionalProperties: O.some(false),
|
|
@@ -63,6 +65,7 @@ describe('GenerateInputType', () => {
|
|
|
63
65
|
in: O.none,
|
|
64
66
|
},
|
|
65
67
|
userId: {
|
|
68
|
+
title: O.none,
|
|
66
69
|
type: O.some('integer'),
|
|
67
70
|
properties: O.none,
|
|
68
71
|
additionalProperties: O.some(false),
|
|
@@ -74,6 +77,7 @@ describe('GenerateInputType', () => {
|
|
|
74
77
|
in: O.none,
|
|
75
78
|
},
|
|
76
79
|
title: {
|
|
80
|
+
title: O.none,
|
|
77
81
|
type: O.some('string'),
|
|
78
82
|
properties: O.none,
|
|
79
83
|
additionalProperties: O.some(false),
|
|
@@ -85,6 +89,7 @@ describe('GenerateInputType', () => {
|
|
|
85
89
|
in: O.none,
|
|
86
90
|
},
|
|
87
91
|
body: {
|
|
92
|
+
title: O.none,
|
|
88
93
|
type: O.some('string'),
|
|
89
94
|
properties: O.none,
|
|
90
95
|
additionalProperties: O.some(false),
|
|
@@ -112,10 +117,12 @@ describe('GenerateInputType', () => {
|
|
|
112
117
|
throw new Error('Should have been right');
|
|
113
118
|
})((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
|
|
114
119
|
const expectedInputSchema = {
|
|
120
|
+
title: O.none,
|
|
115
121
|
type: O.some('object'),
|
|
116
122
|
required: O.some(['id', 'userId', 'title', 'body']),
|
|
117
123
|
properties: O.some({
|
|
118
124
|
id: {
|
|
125
|
+
title: O.none,
|
|
119
126
|
type: O.some('integer'),
|
|
120
127
|
properties: O.none,
|
|
121
128
|
additionalProperties: O.some(false),
|
|
@@ -127,6 +134,7 @@ describe('GenerateInputType', () => {
|
|
|
127
134
|
in: O.some('body'),
|
|
128
135
|
},
|
|
129
136
|
userId: {
|
|
137
|
+
title: O.none,
|
|
130
138
|
type: O.some('integer'),
|
|
131
139
|
properties: O.none,
|
|
132
140
|
additionalProperties: O.some(false),
|
|
@@ -138,6 +146,7 @@ describe('GenerateInputType', () => {
|
|
|
138
146
|
in: O.some('body'),
|
|
139
147
|
},
|
|
140
148
|
title: {
|
|
149
|
+
title: O.none,
|
|
141
150
|
type: O.some('string'),
|
|
142
151
|
properties: O.none,
|
|
143
152
|
additionalProperties: O.some(false),
|
|
@@ -149,6 +158,7 @@ describe('GenerateInputType', () => {
|
|
|
149
158
|
in: O.some('body'),
|
|
150
159
|
},
|
|
151
160
|
body: {
|
|
161
|
+
title: O.none,
|
|
152
162
|
type: O.some('string'),
|
|
153
163
|
properties: O.none,
|
|
154
164
|
additionalProperties: O.some(false),
|
|
@@ -181,6 +191,7 @@ describe('GenerateInputType', () => {
|
|
|
181
191
|
required: O.some(true),
|
|
182
192
|
description: 'The user id.',
|
|
183
193
|
schema: {
|
|
194
|
+
title: O.none,
|
|
184
195
|
type: O.some('integer'),
|
|
185
196
|
format: O.some('int64'),
|
|
186
197
|
properties: O.none,
|
|
@@ -199,6 +210,7 @@ describe('GenerateInputType', () => {
|
|
|
199
210
|
required: O.some(false),
|
|
200
211
|
description: 'The category id.',
|
|
201
212
|
schema: {
|
|
213
|
+
title: O.none,
|
|
202
214
|
type: O.some('integer'),
|
|
203
215
|
format: O.some('int64'),
|
|
204
216
|
properties: O.none,
|
|
@@ -216,10 +228,12 @@ describe('GenerateInputType', () => {
|
|
|
216
228
|
content: {
|
|
217
229
|
'application/json': {
|
|
218
230
|
schema: O.some({
|
|
231
|
+
title: O.none,
|
|
219
232
|
type: O.some('object'),
|
|
220
233
|
required: O.some(['userId', 'body']),
|
|
221
234
|
properties: O.some({
|
|
222
235
|
userId: {
|
|
236
|
+
title: O.none,
|
|
223
237
|
type: O.some('integer'),
|
|
224
238
|
properties: O.none,
|
|
225
239
|
additionalProperties: O.some(false),
|
|
@@ -231,6 +245,7 @@ describe('GenerateInputType', () => {
|
|
|
231
245
|
in: O.none,
|
|
232
246
|
},
|
|
233
247
|
title: {
|
|
248
|
+
title: O.none,
|
|
234
249
|
type: O.some('string'),
|
|
235
250
|
properties: O.none,
|
|
236
251
|
required: O.none,
|
|
@@ -242,6 +257,7 @@ describe('GenerateInputType', () => {
|
|
|
242
257
|
in: O.none,
|
|
243
258
|
},
|
|
244
259
|
body: {
|
|
260
|
+
title: O.none,
|
|
245
261
|
type: O.some('string'),
|
|
246
262
|
properties: O.none,
|
|
247
263
|
additionalProperties: O.some(false),
|
|
@@ -318,6 +334,7 @@ describe('GenerateInputType', () => {
|
|
|
318
334
|
content: {
|
|
319
335
|
'application/json': {
|
|
320
336
|
schema: O.some({
|
|
337
|
+
title: O.none,
|
|
321
338
|
type: O.some('object'),
|
|
322
339
|
required: O.none,
|
|
323
340
|
properties: O.none,
|
|
@@ -356,10 +373,12 @@ describe('GenerateInputType', () => {
|
|
|
356
373
|
content: {
|
|
357
374
|
'unsupported-media-type': {
|
|
358
375
|
schema: O.some({
|
|
376
|
+
title: O.none,
|
|
359
377
|
type: O.some('object'),
|
|
360
378
|
required: O.some(['id', 'userId', 'title', 'body']),
|
|
361
379
|
properties: O.some({
|
|
362
380
|
id: {
|
|
381
|
+
title: O.none,
|
|
363
382
|
type: O.some('integer'),
|
|
364
383
|
properties: O.none,
|
|
365
384
|
required: O.none,
|
|
@@ -371,6 +390,7 @@ describe('GenerateInputType', () => {
|
|
|
371
390
|
in: O.none,
|
|
372
391
|
},
|
|
373
392
|
userId: {
|
|
393
|
+
title: O.none,
|
|
374
394
|
type: O.some('integer'),
|
|
375
395
|
properties: O.none,
|
|
376
396
|
required: O.none,
|
|
@@ -382,6 +402,7 @@ describe('GenerateInputType', () => {
|
|
|
382
402
|
in: O.none,
|
|
383
403
|
},
|
|
384
404
|
title: {
|
|
405
|
+
title: O.none,
|
|
385
406
|
type: O.some('string'),
|
|
386
407
|
properties: O.none,
|
|
387
408
|
required: O.none,
|
|
@@ -393,6 +414,7 @@ describe('GenerateInputType', () => {
|
|
|
393
414
|
in: O.none,
|
|
394
415
|
},
|
|
395
416
|
body: {
|
|
417
|
+
title: O.none,
|
|
396
418
|
type: O.some('string'),
|
|
397
419
|
properties: O.none,
|
|
398
420
|
required: O.none,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateInputTypes.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateInputTypes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"GenerateInputTypes.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateInputTypes.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAKvC,OAAO,EACN,YAAY,EAEZ,MAAM,8BAA8B,CAAC;AAWtC,eAAO,MAAM,kBAAkB,2BACN,MAAM,cAClB,YAAY,KACtB,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAc7B,CAAC"}
|
|
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
26
26
|
exports.generateInputTypes = void 0;
|
|
27
27
|
const json_schema_to_typescript_1 = require("json-schema-to-typescript");
|
|
28
28
|
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
29
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
29
30
|
const CompositeCodec_1 = require("@trayio/commons/codec/CompositeCodec");
|
|
30
31
|
const RemoveNullValuesCodec_1 = require("@trayio/commons/codec/RemoveNullValuesCodec");
|
|
31
32
|
const JsonSchemaToTypescriptOptions_1 = require("./JsonSchemaToTypescriptOptions");
|
|
@@ -35,6 +36,9 @@ const encodeInputSchema = (inputSchema) => {
|
|
|
35
36
|
return codecWithNullValueRemoval.encode(inputSchema);
|
|
36
37
|
};
|
|
37
38
|
const generateInputTypes = (operationNameCamelCase, parameters) => {
|
|
39
|
+
if (O.isSome(parameters.title)) {
|
|
40
|
+
parameters.title = O.none;
|
|
41
|
+
}
|
|
38
42
|
const resolvedInputSchema = encodeInputSchema(parameters);
|
|
39
43
|
return TE.tryCatch(() => (0, json_schema_to_typescript_1.compile)(resolvedInputSchema, `${operationNameCamelCase}Input`, JsonSchemaToTypescriptOptions_1.JsonSchemaToTypescriptOptions), (reason) => new Error(`${reason}`));
|
|
40
44
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateOutput.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateOutput.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,OAAO,EACN,SAAS,EAET,eAAe,EACf,YAAY,EAEZ,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"GenerateOutput.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateOutput.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAKlC,OAAO,EACN,SAAS,EAET,eAAe,EACf,YAAY,EAEZ,MAAM,8BAA8B,CAAC;AAwCtC,eAAO,MAAM,2BAA2B,YAC9B,OAAO,MAAM,EAAE,eAAe,CAAC,KACtC,EAAE,MAAM,CAAC,KAAK,EAAE,eAAe,CAWjC,CAAC;AAEF,eAAO,MAAM,oBAAoB,cACrB,EAAE,MAAM,CAAC,SAAS,CAAC,KAC5B,GAAG,UAAU,CAAC,KAAK,EAAE,YAAY,CAelC,CAAC;AAWH,eAAO,MAAM,mBAAmB,2BACP,MAAM,gBAChB,YAAY,KACxB,GAAG,UAAU,CAAC,KAAK,EAAE,MAAM,CAgB7B,CAAC"}
|
|
@@ -42,6 +42,7 @@ const get2XXResponse = (responses) => O.fold(() => TE.left(new Error('No respons
|
|
|
42
42
|
return TE.left(new Error(`Unsupported success response code: ${responseCodes}`));
|
|
43
43
|
})(responses);
|
|
44
44
|
const blankOutputSchema = () => ({
|
|
45
|
+
title: O.none,
|
|
45
46
|
type: O.none,
|
|
46
47
|
properties: O.none,
|
|
47
48
|
required: O.none,
|
|
@@ -71,6 +72,9 @@ const encodeOutputSchema = (outputSchema) => {
|
|
|
71
72
|
return codecWithNullValueRemoval.encode(outputSchema);
|
|
72
73
|
};
|
|
73
74
|
const generateOutputTypes = (operationNameCamelCase, outputSchema) => {
|
|
75
|
+
if (O.isSome(outputSchema.title)) {
|
|
76
|
+
outputSchema.title = O.none;
|
|
77
|
+
}
|
|
74
78
|
const resolvedOutputSchema = encodeOutputSchema(outputSchema);
|
|
75
79
|
return TE.tryCatch(() => (0, json_schema_to_typescript_1.compile)(resolvedOutputSchema, `${operationNameCamelCase}Output`, JsonSchemaToTypescriptOptions_1.JsonSchemaToTypescriptOptions), (error) => new Error(`Failed to generate output types: ${error}`));
|
|
76
80
|
};
|
|
@@ -55,10 +55,12 @@ describe('Generate output: ', () => {
|
|
|
55
55
|
content: O.some({
|
|
56
56
|
'application/json': {
|
|
57
57
|
schema: O.some({
|
|
58
|
+
title: O.some('Post'),
|
|
58
59
|
type: O.some('object'),
|
|
59
60
|
required: O.some(['id', 'userId', 'title', 'body']),
|
|
60
61
|
properties: O.some({
|
|
61
62
|
id: {
|
|
63
|
+
title: O.none,
|
|
62
64
|
type: O.some('integer'),
|
|
63
65
|
properties: O.none,
|
|
64
66
|
required: O.none,
|
|
@@ -70,6 +72,7 @@ describe('Generate output: ', () => {
|
|
|
70
72
|
in: O.none,
|
|
71
73
|
},
|
|
72
74
|
userId: {
|
|
75
|
+
title: O.none,
|
|
73
76
|
type: O.some('integer'),
|
|
74
77
|
properties: O.none,
|
|
75
78
|
required: O.none,
|
|
@@ -81,6 +84,7 @@ describe('Generate output: ', () => {
|
|
|
81
84
|
in: O.none,
|
|
82
85
|
},
|
|
83
86
|
title: {
|
|
87
|
+
title: O.none,
|
|
84
88
|
type: O.some('string'),
|
|
85
89
|
properties: O.none,
|
|
86
90
|
required: O.none,
|
|
@@ -92,6 +96,7 @@ describe('Generate output: ', () => {
|
|
|
92
96
|
in: O.none,
|
|
93
97
|
},
|
|
94
98
|
body: {
|
|
99
|
+
title: O.none,
|
|
95
100
|
type: O.some('string'),
|
|
96
101
|
properties: O.none,
|
|
97
102
|
required: O.none,
|
|
@@ -131,10 +136,12 @@ describe('Generate output: ', () => {
|
|
|
131
136
|
content: O.some({
|
|
132
137
|
'application/json': {
|
|
133
138
|
schema: O.some({
|
|
139
|
+
title: O.none,
|
|
134
140
|
type: O.some('object'),
|
|
135
141
|
required: O.some(['id', 'userId', 'title', 'body']),
|
|
136
142
|
properties: O.some({
|
|
137
143
|
id: {
|
|
144
|
+
title: O.none,
|
|
138
145
|
type: O.some('integer'),
|
|
139
146
|
properties: O.none,
|
|
140
147
|
required: O.none,
|
|
@@ -146,6 +153,7 @@ describe('Generate output: ', () => {
|
|
|
146
153
|
in: O.none,
|
|
147
154
|
},
|
|
148
155
|
userId: {
|
|
156
|
+
title: O.none,
|
|
149
157
|
type: O.some('integer'),
|
|
150
158
|
properties: O.none,
|
|
151
159
|
required: O.none,
|
|
@@ -157,6 +165,7 @@ describe('Generate output: ', () => {
|
|
|
157
165
|
in: O.none,
|
|
158
166
|
},
|
|
159
167
|
title: {
|
|
168
|
+
title: O.none,
|
|
160
169
|
type: O.some('string'),
|
|
161
170
|
properties: O.none,
|
|
162
171
|
required: O.none,
|
|
@@ -168,6 +177,7 @@ describe('Generate output: ', () => {
|
|
|
168
177
|
in: O.none,
|
|
169
178
|
},
|
|
170
179
|
body: {
|
|
180
|
+
title: O.none,
|
|
171
181
|
type: O.some('string'),
|
|
172
182
|
properties: O.none,
|
|
173
183
|
required: O.none,
|