@trayio/tray-openapi 5.35.0-unstable.fd7158a → 6.0.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/OpenApiCodecs.d.ts +4 -207
- package/dist/OpenApiCodecs.d.ts.map +1 -1
- package/dist/OpenApiCodecs.js +3 -3
- package/dist/OpenApiSchemaImporter.d.ts +2 -2
- package/dist/OpenApiSchemaImporter.d.ts.map +1 -1
- package/dist/OpenApiSchemaImporter.js +55 -33
- package/dist/OpenApiSchemaImporter.unit.test.js +13 -24
- package/dist/OpenApiSchemaTransformer.d.ts +2 -2
- package/dist/OpenApiSchemaTransformer.d.ts.map +1 -1
- package/dist/OpenApiSchemaTransformer.js +25 -2
- package/dist/OpenApiSchemaTransformer.unit.test.js +44 -30
- package/dist/OpenApiTypeDescriptors.d.ts +32 -389
- package/dist/OpenApiTypeDescriptors.d.ts.map +1 -1
- package/dist/OpenApiTypeDescriptors.js +109 -80
- package/dist/file-generators/GenerateHandler.d.ts +2 -2
- package/dist/file-generators/GenerateHandler.d.ts.map +1 -1
- package/dist/file-generators/GenerateHandler.js +78 -75
- package/dist/file-generators/GenerateHandler.unit.test.js +97 -73
- package/dist/file-generators/GenerateHandlerTest.d.ts +2 -2
- package/dist/file-generators/GenerateHandlerTest.d.ts.map +1 -1
- package/dist/file-generators/GenerateHandlerTest.js +76 -69
- package/dist/file-generators/GenerateHandlerTest.unit.test.js +230 -206
- package/dist/file-generators/GenerateOperationJson.d.ts +2 -2
- package/dist/file-generators/GenerateOperationJson.d.ts.map +1 -1
- package/dist/file-generators/GenerateOperationJson.js +29 -4
- package/dist/file-generators/GenerateOperationJson.unit.test.js +49 -25
- package/dist/file-generators/SchemaGenerator.d.ts.map +1 -1
- package/dist/file-generators/SchemaGenerator.js +37 -14
- package/dist/file-generators/types/GenerateInputSchema.d.ts +2 -2
- package/dist/file-generators/types/GenerateInputSchema.d.ts.map +1 -1
- package/dist/file-generators/types/GenerateInputSchema.js +95 -88
- package/dist/file-generators/types/GenerateInputSchema.test.js +91 -60
- package/dist/file-generators/types/GenerateInputType.test.js +169 -143
- package/dist/file-generators/types/GenerateInputTypes.d.ts +2 -2
- package/dist/file-generators/types/GenerateInputTypes.d.ts.map +1 -1
- package/dist/file-generators/types/GenerateInputTypes.js +28 -7
- package/dist/file-generators/types/GenerateOutput.d.ts +6 -4
- package/dist/file-generators/types/GenerateOutput.d.ts.map +1 -1
- package/dist/file-generators/types/GenerateOutput.js +57 -46
- package/dist/file-generators/types/GenerateOutput.test.js +62 -35
- package/package.json +8 -6
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const
|
|
26
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
27
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
28
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
4
29
|
const GenerateInputSchema_1 = require("./GenerateInputSchema");
|
|
5
30
|
const GenerateInputTypes_1 = require("./GenerateInputTypes");
|
|
6
31
|
const SchemaGenerator_1 = require("../SchemaGenerator");
|
|
@@ -8,178 +33,175 @@ describe('GenerateInputType', () => {
|
|
|
8
33
|
it('it should generate a schema from an endpoint with body parameters', async () => {
|
|
9
34
|
const endpoint = {
|
|
10
35
|
operationId: 'createPost',
|
|
11
|
-
description:
|
|
12
|
-
summary:
|
|
13
|
-
tags:
|
|
14
|
-
parameters:
|
|
15
|
-
requestBody:
|
|
36
|
+
description: O.some('Create a new post'),
|
|
37
|
+
summary: O.none,
|
|
38
|
+
tags: O.some([]),
|
|
39
|
+
parameters: O.none,
|
|
40
|
+
requestBody: O.some({
|
|
16
41
|
content: {
|
|
17
42
|
'application/json': {
|
|
18
|
-
schema:
|
|
19
|
-
type:
|
|
20
|
-
required:
|
|
21
|
-
properties:
|
|
43
|
+
schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
44
|
+
type: O.some('object'),
|
|
45
|
+
required: O.some(['id', 'userId', 'title', 'body']),
|
|
46
|
+
properties: O.some({
|
|
22
47
|
id: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
23
|
-
type:
|
|
24
|
-
additionalProperties:
|
|
48
|
+
type: O.some('integer'),
|
|
49
|
+
additionalProperties: O.some(false),
|
|
25
50
|
}),
|
|
26
51
|
userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
27
|
-
type:
|
|
28
|
-
additionalProperties:
|
|
52
|
+
type: O.some('integer'),
|
|
53
|
+
additionalProperties: O.some(false),
|
|
29
54
|
}),
|
|
30
55
|
title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
31
|
-
title:
|
|
32
|
-
type:
|
|
33
|
-
additionalProperties:
|
|
56
|
+
title: O.none,
|
|
57
|
+
type: O.some('string'),
|
|
58
|
+
additionalProperties: O.some(false),
|
|
34
59
|
}),
|
|
35
60
|
body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
36
|
-
type:
|
|
37
|
-
additionalProperties:
|
|
61
|
+
type: O.some('string'),
|
|
62
|
+
additionalProperties: O.some(false),
|
|
38
63
|
}),
|
|
39
64
|
}),
|
|
40
|
-
additionalProperties:
|
|
65
|
+
additionalProperties: O.some(false),
|
|
41
66
|
})),
|
|
42
67
|
},
|
|
43
68
|
},
|
|
44
69
|
}),
|
|
45
|
-
responses:
|
|
70
|
+
responses: O.none,
|
|
46
71
|
};
|
|
47
|
-
const inputSchema =
|
|
72
|
+
const inputSchema = E.getOrElse(() => {
|
|
48
73
|
throw new Error('Should have been right');
|
|
49
74
|
})((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
|
|
50
75
|
const expectedInputSchema = {
|
|
51
|
-
title:
|
|
52
|
-
type:
|
|
53
|
-
required:
|
|
54
|
-
properties:
|
|
76
|
+
title: O.none,
|
|
77
|
+
type: O.some('object'),
|
|
78
|
+
required: O.some(['id', 'userId', 'title', 'body']),
|
|
79
|
+
properties: O.some({
|
|
55
80
|
id: {
|
|
56
|
-
title:
|
|
57
|
-
type:
|
|
58
|
-
properties:
|
|
59
|
-
additionalProperties:
|
|
60
|
-
required:
|
|
61
|
-
allOf:
|
|
62
|
-
anyOf:
|
|
63
|
-
oneOf:
|
|
64
|
-
not:
|
|
65
|
-
in:
|
|
66
|
-
default:
|
|
67
|
-
nullable:
|
|
68
|
-
enum: effect_1.Option.none(),
|
|
81
|
+
title: O.none,
|
|
82
|
+
type: O.some('integer'),
|
|
83
|
+
properties: O.none,
|
|
84
|
+
additionalProperties: O.some(false),
|
|
85
|
+
required: O.none,
|
|
86
|
+
allOf: O.none,
|
|
87
|
+
anyOf: O.none,
|
|
88
|
+
oneOf: O.none,
|
|
89
|
+
not: O.none,
|
|
90
|
+
in: O.some('body'),
|
|
91
|
+
default: O.none,
|
|
92
|
+
nullable: O.none,
|
|
69
93
|
},
|
|
70
94
|
userId: {
|
|
71
|
-
title:
|
|
72
|
-
type:
|
|
73
|
-
properties:
|
|
74
|
-
additionalProperties:
|
|
75
|
-
required:
|
|
76
|
-
allOf:
|
|
77
|
-
anyOf:
|
|
78
|
-
oneOf:
|
|
79
|
-
not:
|
|
80
|
-
in:
|
|
81
|
-
default:
|
|
82
|
-
nullable:
|
|
83
|
-
enum: effect_1.Option.none(),
|
|
95
|
+
title: O.none,
|
|
96
|
+
type: O.some('integer'),
|
|
97
|
+
properties: O.none,
|
|
98
|
+
additionalProperties: O.some(false),
|
|
99
|
+
required: O.none,
|
|
100
|
+
allOf: O.none,
|
|
101
|
+
anyOf: O.none,
|
|
102
|
+
oneOf: O.none,
|
|
103
|
+
not: O.none,
|
|
104
|
+
in: O.some('body'),
|
|
105
|
+
default: O.none,
|
|
106
|
+
nullable: O.none,
|
|
84
107
|
},
|
|
85
108
|
title: {
|
|
86
|
-
title:
|
|
87
|
-
type:
|
|
88
|
-
properties:
|
|
89
|
-
additionalProperties:
|
|
90
|
-
required:
|
|
91
|
-
allOf:
|
|
92
|
-
anyOf:
|
|
93
|
-
oneOf:
|
|
94
|
-
not:
|
|
95
|
-
in:
|
|
96
|
-
default:
|
|
97
|
-
nullable:
|
|
98
|
-
enum: effect_1.Option.none(),
|
|
109
|
+
title: O.none,
|
|
110
|
+
type: O.some('string'),
|
|
111
|
+
properties: O.none,
|
|
112
|
+
additionalProperties: O.some(false),
|
|
113
|
+
required: O.none,
|
|
114
|
+
allOf: O.none,
|
|
115
|
+
anyOf: O.none,
|
|
116
|
+
oneOf: O.none,
|
|
117
|
+
not: O.none,
|
|
118
|
+
in: O.some('body'),
|
|
119
|
+
default: O.none,
|
|
120
|
+
nullable: O.none,
|
|
99
121
|
},
|
|
100
122
|
body: {
|
|
101
|
-
title:
|
|
102
|
-
type:
|
|
103
|
-
properties:
|
|
104
|
-
additionalProperties:
|
|
105
|
-
required:
|
|
106
|
-
allOf:
|
|
107
|
-
anyOf:
|
|
108
|
-
oneOf:
|
|
109
|
-
not:
|
|
110
|
-
in:
|
|
111
|
-
default:
|
|
112
|
-
nullable:
|
|
113
|
-
enum: effect_1.Option.none(),
|
|
123
|
+
title: O.none,
|
|
124
|
+
type: O.some('string'),
|
|
125
|
+
properties: O.none,
|
|
126
|
+
additionalProperties: O.some(false),
|
|
127
|
+
required: O.none,
|
|
128
|
+
allOf: O.none,
|
|
129
|
+
anyOf: O.none,
|
|
130
|
+
oneOf: O.none,
|
|
131
|
+
not: O.none,
|
|
132
|
+
in: O.some('body'),
|
|
133
|
+
default: O.none,
|
|
134
|
+
nullable: O.none,
|
|
114
135
|
},
|
|
115
136
|
}),
|
|
116
|
-
additionalProperties:
|
|
117
|
-
allOf:
|
|
118
|
-
anyOf:
|
|
119
|
-
oneOf:
|
|
120
|
-
not:
|
|
121
|
-
in:
|
|
122
|
-
default:
|
|
123
|
-
nullable:
|
|
124
|
-
enum: effect_1.Option.none(),
|
|
137
|
+
additionalProperties: O.some(false),
|
|
138
|
+
allOf: O.none,
|
|
139
|
+
anyOf: O.none,
|
|
140
|
+
oneOf: O.none,
|
|
141
|
+
not: O.none,
|
|
142
|
+
in: O.none,
|
|
143
|
+
default: O.none,
|
|
144
|
+
nullable: O.none,
|
|
125
145
|
};
|
|
126
146
|
expect(inputSchema).toEqual(expectedInputSchema);
|
|
127
147
|
});
|
|
128
148
|
it('it should process an endpoint with path, query string and body parameters and generate input.ts file contents', async () => {
|
|
129
149
|
const endpoint = {
|
|
130
150
|
operationId: 'getPost',
|
|
131
|
-
description:
|
|
132
|
-
summary:
|
|
133
|
-
tags:
|
|
134
|
-
parameters:
|
|
151
|
+
description: O.some('Get a post by id'),
|
|
152
|
+
summary: O.none,
|
|
153
|
+
tags: O.some([]),
|
|
154
|
+
parameters: O.some([
|
|
135
155
|
{
|
|
136
156
|
name: 'id',
|
|
137
157
|
in: 'path',
|
|
138
|
-
required:
|
|
139
|
-
description:
|
|
158
|
+
required: O.some(true),
|
|
159
|
+
description: O.some('The user id.'),
|
|
140
160
|
schema: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
141
|
-
type:
|
|
161
|
+
type: O.some('integer'),
|
|
142
162
|
}),
|
|
143
163
|
},
|
|
144
164
|
{
|
|
145
165
|
name: 'categoryId',
|
|
146
166
|
in: 'path',
|
|
147
|
-
required:
|
|
148
|
-
description:
|
|
167
|
+
required: O.some(false),
|
|
168
|
+
description: O.some('The category id.'),
|
|
149
169
|
schema: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
150
|
-
title:
|
|
151
|
-
type:
|
|
170
|
+
title: O.none,
|
|
171
|
+
type: O.some('integer'),
|
|
152
172
|
}),
|
|
153
173
|
},
|
|
154
174
|
]),
|
|
155
|
-
requestBody:
|
|
175
|
+
requestBody: O.some({
|
|
156
176
|
content: {
|
|
157
177
|
'application/json': {
|
|
158
|
-
schema:
|
|
159
|
-
type:
|
|
160
|
-
required:
|
|
161
|
-
properties:
|
|
178
|
+
schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
179
|
+
type: O.some('object'),
|
|
180
|
+
required: O.some(['userId', 'body']),
|
|
181
|
+
properties: O.some({
|
|
162
182
|
userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
163
|
-
type:
|
|
183
|
+
type: O.some('integer'),
|
|
164
184
|
}),
|
|
165
185
|
title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
166
|
-
type:
|
|
186
|
+
type: O.some('string'),
|
|
167
187
|
}),
|
|
168
188
|
body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
169
|
-
type:
|
|
189
|
+
type: O.some('string'),
|
|
170
190
|
}),
|
|
171
191
|
}),
|
|
172
192
|
})),
|
|
173
193
|
},
|
|
174
194
|
},
|
|
175
195
|
}),
|
|
176
|
-
responses:
|
|
196
|
+
responses: O.none,
|
|
177
197
|
};
|
|
178
|
-
const inputSchema =
|
|
198
|
+
const inputSchema = E.getOrElse(() => {
|
|
179
199
|
throw new Error('Should have been right');
|
|
180
200
|
})((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
|
|
181
201
|
const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
|
|
182
|
-
const generatedInputFile = await
|
|
202
|
+
const generatedInputFile = await TE.getOrElse((error) => {
|
|
203
|
+
throw new Error('Should have been right');
|
|
204
|
+
})(inputTypes)();
|
|
183
205
|
const expectedInputFile = `export interface GetPostInput {
|
|
184
206
|
userId: number;
|
|
185
207
|
title?: string;
|
|
@@ -199,18 +221,20 @@ describe('GenerateInputType', () => {
|
|
|
199
221
|
it('it should process an endpoint with no parameters and generate empty input.ts file contents', async () => {
|
|
200
222
|
const endpoint = {
|
|
201
223
|
operationId: 'getPosts',
|
|
202
|
-
description:
|
|
203
|
-
summary:
|
|
204
|
-
tags:
|
|
205
|
-
parameters:
|
|
206
|
-
requestBody:
|
|
207
|
-
responses:
|
|
224
|
+
description: O.some('Get all posts'),
|
|
225
|
+
summary: O.none,
|
|
226
|
+
tags: O.some([]),
|
|
227
|
+
parameters: O.none,
|
|
228
|
+
requestBody: O.none,
|
|
229
|
+
responses: O.none,
|
|
208
230
|
};
|
|
209
|
-
const inputSchema =
|
|
231
|
+
const inputSchema = E.getOrElse(() => {
|
|
210
232
|
throw new Error('Should have been right');
|
|
211
233
|
})((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
|
|
212
234
|
const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
|
|
213
|
-
const generatedInputFile = await
|
|
235
|
+
const generatedInputFile = await TE.getOrElse((error) => {
|
|
236
|
+
throw new Error('Should have been right');
|
|
237
|
+
})(inputTypes)();
|
|
214
238
|
const expectedInputFile = `export interface GetPostsInput {}
|
|
215
239
|
`;
|
|
216
240
|
expect(generatedInputFile).toEqual(expectedInputFile);
|
|
@@ -218,27 +242,29 @@ describe('GenerateInputType', () => {
|
|
|
218
242
|
it('it should process an endpoint with a body schema with no parameters and additionalProperties: true and generate k: string: unknown input.ts file contents', async () => {
|
|
219
243
|
const endpoint = {
|
|
220
244
|
operationId: 'getPosts',
|
|
221
|
-
description:
|
|
222
|
-
summary:
|
|
223
|
-
tags:
|
|
224
|
-
parameters:
|
|
225
|
-
requestBody:
|
|
245
|
+
description: O.some('Get all posts'),
|
|
246
|
+
summary: O.none,
|
|
247
|
+
tags: O.some([]),
|
|
248
|
+
parameters: O.none,
|
|
249
|
+
requestBody: O.some({
|
|
226
250
|
content: {
|
|
227
251
|
'application/json': {
|
|
228
|
-
schema:
|
|
229
|
-
type:
|
|
230
|
-
additionalProperties:
|
|
252
|
+
schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
253
|
+
type: O.some('object'),
|
|
254
|
+
additionalProperties: O.some(true),
|
|
231
255
|
})),
|
|
232
256
|
},
|
|
233
257
|
},
|
|
234
258
|
}),
|
|
235
|
-
responses:
|
|
259
|
+
responses: O.none,
|
|
236
260
|
};
|
|
237
|
-
const inputSchema =
|
|
261
|
+
const inputSchema = E.getOrElse(() => {
|
|
238
262
|
throw new Error('Should have been right');
|
|
239
263
|
})((0, GenerateInputSchema_1.generateInputSchema)(endpoint));
|
|
240
264
|
const inputTypes = (0, GenerateInputTypes_1.generateInputTypes)(endpoint.operationId, inputSchema);
|
|
241
|
-
const generatedInputFile = await
|
|
265
|
+
const generatedInputFile = await TE.getOrElse((error) => {
|
|
266
|
+
throw new Error('Should have been right');
|
|
267
|
+
})(inputTypes)();
|
|
242
268
|
const expectedInputFile = `export interface GetPostsInput {
|
|
243
269
|
[k: string]: unknown;
|
|
244
270
|
}
|
|
@@ -248,38 +274,38 @@ describe('GenerateInputType', () => {
|
|
|
248
274
|
it('it should throw an exception when finding an unsupported media type', async () => {
|
|
249
275
|
const endpoint = {
|
|
250
276
|
operationId: 'createPost',
|
|
251
|
-
description:
|
|
252
|
-
summary:
|
|
253
|
-
tags:
|
|
254
|
-
parameters:
|
|
255
|
-
requestBody:
|
|
277
|
+
description: O.some('Create a new post'),
|
|
278
|
+
summary: O.none,
|
|
279
|
+
tags: O.some([]),
|
|
280
|
+
parameters: O.none,
|
|
281
|
+
requestBody: O.some({
|
|
256
282
|
content: {
|
|
257
283
|
'unsupported-media-type': {
|
|
258
|
-
schema:
|
|
259
|
-
type:
|
|
260
|
-
required:
|
|
261
|
-
properties:
|
|
284
|
+
schema: O.some((0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
285
|
+
type: O.some('object'),
|
|
286
|
+
required: O.some(['id', 'userId', 'title', 'body']),
|
|
287
|
+
properties: O.some({
|
|
262
288
|
id: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
263
|
-
type:
|
|
289
|
+
type: O.some('integer'),
|
|
264
290
|
}),
|
|
265
291
|
userId: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
266
|
-
type:
|
|
292
|
+
type: O.some('integer'),
|
|
267
293
|
}),
|
|
268
294
|
title: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
269
|
-
type:
|
|
295
|
+
type: O.some('string'),
|
|
270
296
|
}),
|
|
271
297
|
body: (0, SchemaGenerator_1.generateNonArraySchemaObject)({
|
|
272
|
-
type:
|
|
298
|
+
type: O.some('string'),
|
|
273
299
|
}),
|
|
274
300
|
}),
|
|
275
301
|
})),
|
|
276
302
|
},
|
|
277
303
|
},
|
|
278
304
|
}),
|
|
279
|
-
responses:
|
|
305
|
+
responses: O.none,
|
|
280
306
|
};
|
|
281
307
|
const inputSchema = (0, GenerateInputSchema_1.generateInputSchema)(endpoint);
|
|
282
|
-
if (
|
|
308
|
+
if (E.isRight(inputSchema)) {
|
|
283
309
|
throw new Error('Should have been left');
|
|
284
310
|
}
|
|
285
311
|
expect(inputSchema.left.message).toEqual('Unsupported media type: unsupported-media-type');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
2
2
|
import { SchemaObject } from '../../OpenApiTypeDescriptors';
|
|
3
|
-
export declare const generateInputTypes: (operationNameCamelCase: string, parameters: SchemaObject) =>
|
|
3
|
+
export declare const generateInputTypes: (operationNameCamelCase: string, parameters: SchemaObject) => TE.TaskEither<Error, string>;
|
|
4
4
|
//# sourceMappingURL=GenerateInputTypes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateInputTypes.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateInputTypes.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,8 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
26
|
exports.generateInputTypes = void 0;
|
|
4
|
-
const effect_1 = require("effect");
|
|
5
27
|
const json_schema_to_typescript_1 = require("json-schema-to-typescript");
|
|
28
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
29
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
6
30
|
const CompositeCodec_1 = require("@trayio/commons/codec/CompositeCodec");
|
|
7
31
|
const RemoveNullValuesCodec_1 = require("@trayio/commons/codec/RemoveNullValuesCodec");
|
|
8
32
|
const JsonSchemaToTypescriptOptions_1 = require("./JsonSchemaToTypescriptOptions");
|
|
@@ -12,13 +36,10 @@ const encodeInputSchema = (inputSchema) => {
|
|
|
12
36
|
return codecWithNullValueRemoval.encode(inputSchema);
|
|
13
37
|
};
|
|
14
38
|
const generateInputTypes = (operationNameCamelCase, parameters) => {
|
|
15
|
-
if (
|
|
16
|
-
parameters.title =
|
|
39
|
+
if (O.isSome(parameters.title)) {
|
|
40
|
+
parameters.title = O.none;
|
|
17
41
|
}
|
|
18
42
|
const resolvedInputSchema = encodeInputSchema(parameters);
|
|
19
|
-
return
|
|
20
|
-
try: () => (0, json_schema_to_typescript_1.compile)(resolvedInputSchema, `${operationNameCamelCase}Input`, JsonSchemaToTypescriptOptions_1.JsonSchemaToTypescriptOptions),
|
|
21
|
-
catch: (reason) => new Error(`${reason}`),
|
|
22
|
-
});
|
|
43
|
+
return TE.tryCatch(() => (0, json_schema_to_typescript_1.compile)(resolvedInputSchema, `${operationNameCamelCase}Input`, JsonSchemaToTypescriptOptions_1.JsonSchemaToTypescriptOptions), (reason) => new Error(`${reason}`));
|
|
23
44
|
};
|
|
24
45
|
exports.generateInputTypes = generateInputTypes;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as TE from 'fp-ts/TaskEither';
|
|
2
|
+
import * as E from 'fp-ts/Either';
|
|
3
|
+
import * as O from 'fp-ts/Option';
|
|
2
4
|
import { Responses, MediaTypeObject, SchemaObject } from '../../OpenApiTypeDescriptors';
|
|
3
|
-
export declare const getApplicationJsonMediaType: (content: Record<string, MediaTypeObject>) =>
|
|
4
|
-
export declare const generateOutputSchema: (responses:
|
|
5
|
-
export declare const generateOutputTypes: (operationNameCamelCase: string, outputSchema: SchemaObject) =>
|
|
5
|
+
export declare const getApplicationJsonMediaType: (content: Record<string, MediaTypeObject>) => E.Either<Error, MediaTypeObject>;
|
|
6
|
+
export declare const generateOutputSchema: (responses: O.Option<Responses>) => TE.TaskEither<Error, SchemaObject>;
|
|
7
|
+
export declare const generateOutputTypes: (operationNameCamelCase: string, outputSchema: SchemaObject) => TE.TaskEither<Error, string>;
|
|
6
8
|
//# sourceMappingURL=GenerateOutput.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GenerateOutput.d.ts","sourceRoot":"","sources":["../../../src/file-generators/types/GenerateOutput.ts"],"names":[],"mappings":"
|
|
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;AA2CtC,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"}
|