@aws/nx-plugin 0.14.2 → 0.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/package.json +2 -2
- package/src/open-api/ts-client/__snapshots__/generator.additional-properties.spec.ts.snap +2236 -0
- package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +2307 -0
- package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +1495 -0
- package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +1470 -0
- package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +1138 -0
- package/src/open-api/ts-client/__snapshots__/generator.response.spec.ts.snap +732 -0
- package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +743 -0
- package/src/open-api/ts-client/files/client.gen.ts.template +52 -15
- package/src/open-api/ts-client/files/types.gen.ts.template +5 -0
- package/src/open-api/ts-hooks/__snapshots__/generator.spec.tsx.snap +1092 -0
- package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +210 -0
- package/src/open-api/ts-hooks/generator.d.ts +5 -0
- package/src/open-api/ts-hooks/generator.js +15 -2
- package/src/open-api/ts-hooks/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.spec.tsx +1787 -0
- package/src/open-api/utils/codegen-data/types.d.ts +25 -0
- package/src/open-api/utils/codegen-data/types.js +26 -1
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.js +187 -79
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +11 -1
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/py/fast-api/react/__snapshots__/generator.spec.ts.snap +120 -10
- package/src/py/fast-api/react/files/website/components/__apiNameClassName__Provider.tsx.template +40 -0
- package/src/py/fast-api/react/files/website/hooks/use__apiNameClassName__.tsx.template +13 -18
- package/src/py/fast-api/react/files/website/hooks/use__apiNameClassName__Client.tsx.template +13 -0
- package/src/py/fast-api/react/generator.js +35 -9
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/project/generator.js +5 -0
- package/src/py/project/generator.js.map +1 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +7 -9
- package/src/utils/files/http-api/common/constructs/src/core/http-api.ts.template +7 -9
- package/src/open-api/ts-client/__snapshots__/generator.spec.ts.snap +0 -7880
|
@@ -0,0 +1,1470 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`openApiTsClientGenerator - primitive types > should generate valid TypeScript for primitive types 1`] = `
|
|
4
|
+
"export type GetTest200Response = {
|
|
5
|
+
string: string;
|
|
6
|
+
number: number;
|
|
7
|
+
integer: number;
|
|
8
|
+
boolean: boolean;
|
|
9
|
+
nullableString?: string | null;
|
|
10
|
+
optionalNumber?: number;
|
|
11
|
+
};
|
|
12
|
+
export type GetTestError = never;
|
|
13
|
+
"
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports[`openApiTsClientGenerator - primitive types > should generate valid TypeScript for primitive types 2`] = `
|
|
17
|
+
"import type { GetTest200Response } from './types.gen.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Utility for serialisation and deserialisation of API types.
|
|
21
|
+
*/
|
|
22
|
+
export class $IO {
|
|
23
|
+
protected static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
24
|
+
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
25
|
+
|
|
26
|
+
public static GetTest200Response = {
|
|
27
|
+
toJson: (model: GetTest200Response): any => {
|
|
28
|
+
if (model === undefined || model === null) {
|
|
29
|
+
return model;
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
...(model.string === undefined
|
|
33
|
+
? {}
|
|
34
|
+
: {
|
|
35
|
+
string: model.string,
|
|
36
|
+
}),
|
|
37
|
+
...(model.number === undefined
|
|
38
|
+
? {}
|
|
39
|
+
: {
|
|
40
|
+
number: model.number,
|
|
41
|
+
}),
|
|
42
|
+
...(model.integer === undefined
|
|
43
|
+
? {}
|
|
44
|
+
: {
|
|
45
|
+
integer: model.integer,
|
|
46
|
+
}),
|
|
47
|
+
...(model.boolean === undefined
|
|
48
|
+
? {}
|
|
49
|
+
: {
|
|
50
|
+
boolean: model.boolean,
|
|
51
|
+
}),
|
|
52
|
+
...(model.nullableString === undefined
|
|
53
|
+
? {}
|
|
54
|
+
: {
|
|
55
|
+
'nullable-string': model.nullableString,
|
|
56
|
+
}),
|
|
57
|
+
...(model.optionalNumber === undefined
|
|
58
|
+
? {}
|
|
59
|
+
: {
|
|
60
|
+
optionalNumber: model.optionalNumber,
|
|
61
|
+
}),
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
fromJson: (json: any): GetTest200Response => {
|
|
65
|
+
if (json === undefined || json === null) {
|
|
66
|
+
return json;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
string: json['string'],
|
|
70
|
+
number: json['number'],
|
|
71
|
+
integer: json['integer'],
|
|
72
|
+
boolean: json['boolean'],
|
|
73
|
+
...(json['nullable-string'] === undefined
|
|
74
|
+
? {}
|
|
75
|
+
: {
|
|
76
|
+
nullableString:
|
|
77
|
+
json['nullable-string'] === null
|
|
78
|
+
? null
|
|
79
|
+
: json['nullable-string'],
|
|
80
|
+
}),
|
|
81
|
+
...(json['optionalNumber'] === undefined
|
|
82
|
+
? {}
|
|
83
|
+
: {
|
|
84
|
+
optionalNumber: json['optionalNumber'],
|
|
85
|
+
}),
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Client configuration for TestApi
|
|
93
|
+
*/
|
|
94
|
+
export interface TestApiConfig {
|
|
95
|
+
/**
|
|
96
|
+
* Base URL for the API
|
|
97
|
+
*/
|
|
98
|
+
url: string;
|
|
99
|
+
/**
|
|
100
|
+
* Custom instance of fetch. By default the global 'fetch' is used.
|
|
101
|
+
* You can override this to add custom middleware for use cases such as adding authentication headers.
|
|
102
|
+
*/
|
|
103
|
+
fetch?: typeof fetch;
|
|
104
|
+
/**
|
|
105
|
+
* Additional configuration
|
|
106
|
+
*/
|
|
107
|
+
options?: {
|
|
108
|
+
/**
|
|
109
|
+
* By default, the client will add a Content-Type header, set to the media type defined for
|
|
110
|
+
* the request in the OpenAPI specification.
|
|
111
|
+
* Set this to false to omit this header.
|
|
112
|
+
*/
|
|
113
|
+
omitContentTypeHeader?: boolean;
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* API Client for TestApi
|
|
119
|
+
*/
|
|
120
|
+
export class TestApi {
|
|
121
|
+
private $config: TestApiConfig;
|
|
122
|
+
|
|
123
|
+
constructor(config: TestApiConfig) {
|
|
124
|
+
this.$config = config;
|
|
125
|
+
|
|
126
|
+
this.getTest = this.getTest.bind(this);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private $url = (
|
|
130
|
+
path: string,
|
|
131
|
+
pathParameters: { [key: string]: any },
|
|
132
|
+
queryParameters: { [key: string]: any },
|
|
133
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
134
|
+
): string => {
|
|
135
|
+
const baseUrl = this.$config.url.endsWith('/')
|
|
136
|
+
? this.$config.url.slice(0, -1)
|
|
137
|
+
: this.$config.url;
|
|
138
|
+
const pathWithParameters = Object.entries(pathParameters).reduce(
|
|
139
|
+
(withParams, [key, value]) =>
|
|
140
|
+
withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
|
|
141
|
+
path,
|
|
142
|
+
);
|
|
143
|
+
const queryString = Object.entries(queryParameters)
|
|
144
|
+
.map(([key, value]) => {
|
|
145
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
146
|
+
return value
|
|
147
|
+
.map(
|
|
148
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
149
|
+
)
|
|
150
|
+
.join('&');
|
|
151
|
+
}
|
|
152
|
+
return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
|
|
153
|
+
})
|
|
154
|
+
.join('&');
|
|
155
|
+
return (
|
|
156
|
+
baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
|
|
157
|
+
);
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
private $headers = (
|
|
161
|
+
headerParameters: { [key: string]: any },
|
|
162
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
163
|
+
): [string, string][] => {
|
|
164
|
+
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
165
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
166
|
+
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
167
|
+
}
|
|
168
|
+
return [[key, String(value)]];
|
|
169
|
+
});
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
private $fetch: typeof fetch = (...args) =>
|
|
173
|
+
(this.$config.fetch ?? fetch)(...args);
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Sends a test request!
|
|
177
|
+
*/
|
|
178
|
+
public async getTest(): Promise<GetTest200Response> {
|
|
179
|
+
const pathParameters: { [key: string]: any } = {};
|
|
180
|
+
const queryParameters: { [key: string]: any } = {};
|
|
181
|
+
const headerParameters: { [key: string]: any } = {};
|
|
182
|
+
|
|
183
|
+
const body = undefined;
|
|
184
|
+
|
|
185
|
+
const response = await this.$fetch(
|
|
186
|
+
this.$url('/test', pathParameters, queryParameters),
|
|
187
|
+
{
|
|
188
|
+
headers: this.$headers(headerParameters),
|
|
189
|
+
method: 'GET',
|
|
190
|
+
body,
|
|
191
|
+
},
|
|
192
|
+
);
|
|
193
|
+
|
|
194
|
+
if (response.status === 200) {
|
|
195
|
+
return $IO.GetTest200Response.fromJson(await response.json());
|
|
196
|
+
}
|
|
197
|
+
throw new Error(
|
|
198
|
+
\`Unknown response status \${response.status} returned by API\`,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
"
|
|
203
|
+
`;
|
|
204
|
+
|
|
205
|
+
exports[`openApiTsClientGenerator - primitive types > should generate valid typescript for openapi v3.1 specifications with null types 1`] = `
|
|
206
|
+
"export type PostTest200Response = {};
|
|
207
|
+
export type PostTestRequestContent = {
|
|
208
|
+
requiredNull: null;
|
|
209
|
+
optionalNull?: null;
|
|
210
|
+
requiredCompositeNull: PostTestRequestContentRequiredCompositeNull;
|
|
211
|
+
optionalCompositeNull?: PostTestRequestContentOptionalCompositeNull;
|
|
212
|
+
};
|
|
213
|
+
export type PostTestRequestContentOptionalCompositeNull = string | null;
|
|
214
|
+
export type PostTestRequestContentRequiredCompositeNull = string | null;
|
|
215
|
+
|
|
216
|
+
export type PostTestRequest = PostTestRequestContent;
|
|
217
|
+
export type PostTestError = never;
|
|
218
|
+
"
|
|
219
|
+
`;
|
|
220
|
+
|
|
221
|
+
exports[`openApiTsClientGenerator - primitive types > should generate valid typescript for openapi v3.1 specifications with null types 2`] = `
|
|
222
|
+
"import type {
|
|
223
|
+
PostTest200Response,
|
|
224
|
+
PostTestRequestContent,
|
|
225
|
+
PostTestRequestContentOptionalCompositeNull,
|
|
226
|
+
PostTestRequestContentRequiredCompositeNull,
|
|
227
|
+
PostTestRequest,
|
|
228
|
+
} from './types.gen.js';
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* Utility for serialisation and deserialisation of API types.
|
|
232
|
+
*/
|
|
233
|
+
export class $IO {
|
|
234
|
+
protected static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
235
|
+
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
236
|
+
|
|
237
|
+
public static PostTest200Response = {
|
|
238
|
+
toJson: (model: PostTest200Response): any => {
|
|
239
|
+
if (model === undefined || model === null) {
|
|
240
|
+
return model;
|
|
241
|
+
}
|
|
242
|
+
return {
|
|
243
|
+
...model,
|
|
244
|
+
};
|
|
245
|
+
},
|
|
246
|
+
fromJson: (json: any): PostTest200Response => {
|
|
247
|
+
if (json === undefined || json === null) {
|
|
248
|
+
return json;
|
|
249
|
+
}
|
|
250
|
+
return {
|
|
251
|
+
...json,
|
|
252
|
+
};
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
public static PostTestRequestContent = {
|
|
257
|
+
toJson: (model: PostTestRequestContent): any => {
|
|
258
|
+
if (model === undefined || model === null) {
|
|
259
|
+
return model;
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
...(model.requiredNull === undefined
|
|
263
|
+
? {}
|
|
264
|
+
: {
|
|
265
|
+
requiredNull: model.requiredNull,
|
|
266
|
+
}),
|
|
267
|
+
...(model.optionalNull === undefined
|
|
268
|
+
? {}
|
|
269
|
+
: {
|
|
270
|
+
optionalNull: model.optionalNull,
|
|
271
|
+
}),
|
|
272
|
+
...(model.requiredCompositeNull === undefined
|
|
273
|
+
? {}
|
|
274
|
+
: {
|
|
275
|
+
requiredCompositeNull:
|
|
276
|
+
$IO.PostTestRequestContentRequiredCompositeNull.toJson(
|
|
277
|
+
model.requiredCompositeNull,
|
|
278
|
+
),
|
|
279
|
+
}),
|
|
280
|
+
...(model.optionalCompositeNull === undefined
|
|
281
|
+
? {}
|
|
282
|
+
: {
|
|
283
|
+
optionalCompositeNull:
|
|
284
|
+
$IO.PostTestRequestContentOptionalCompositeNull.toJson(
|
|
285
|
+
model.optionalCompositeNull,
|
|
286
|
+
),
|
|
287
|
+
}),
|
|
288
|
+
};
|
|
289
|
+
},
|
|
290
|
+
fromJson: (json: any): PostTestRequestContent => {
|
|
291
|
+
if (json === undefined || json === null) {
|
|
292
|
+
return json;
|
|
293
|
+
}
|
|
294
|
+
return {
|
|
295
|
+
requiredNull:
|
|
296
|
+
json['requiredNull'] === null ? null : json['requiredNull'],
|
|
297
|
+
...(json['optionalNull'] === undefined
|
|
298
|
+
? {}
|
|
299
|
+
: {
|
|
300
|
+
optionalNull:
|
|
301
|
+
json['optionalNull'] === null ? null : json['optionalNull'],
|
|
302
|
+
}),
|
|
303
|
+
requiredCompositeNull:
|
|
304
|
+
$IO.PostTestRequestContentRequiredCompositeNull.fromJson(
|
|
305
|
+
json['requiredCompositeNull'],
|
|
306
|
+
),
|
|
307
|
+
...(json['optionalCompositeNull'] === undefined
|
|
308
|
+
? {}
|
|
309
|
+
: {
|
|
310
|
+
optionalCompositeNull:
|
|
311
|
+
$IO.PostTestRequestContentOptionalCompositeNull.fromJson(
|
|
312
|
+
json['optionalCompositeNull'],
|
|
313
|
+
),
|
|
314
|
+
}),
|
|
315
|
+
};
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
public static PostTestRequestContentOptionalCompositeNull = {
|
|
320
|
+
toJson: (model: PostTestRequestContentOptionalCompositeNull): any => {
|
|
321
|
+
if (model === undefined || model === null) {
|
|
322
|
+
return model;
|
|
323
|
+
}
|
|
324
|
+
if (typeof model === 'string') {
|
|
325
|
+
return model;
|
|
326
|
+
}
|
|
327
|
+
return model;
|
|
328
|
+
},
|
|
329
|
+
fromJson: (json: any): PostTestRequestContentOptionalCompositeNull => {
|
|
330
|
+
if (json === undefined || json === null) {
|
|
331
|
+
return json;
|
|
332
|
+
}
|
|
333
|
+
if (typeof json === 'string') {
|
|
334
|
+
return json;
|
|
335
|
+
}
|
|
336
|
+
return json;
|
|
337
|
+
},
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
public static PostTestRequestContentRequiredCompositeNull = {
|
|
341
|
+
toJson: (model: PostTestRequestContentRequiredCompositeNull): any => {
|
|
342
|
+
if (model === undefined || model === null) {
|
|
343
|
+
return model;
|
|
344
|
+
}
|
|
345
|
+
if (typeof model === 'string') {
|
|
346
|
+
return model;
|
|
347
|
+
}
|
|
348
|
+
return model;
|
|
349
|
+
},
|
|
350
|
+
fromJson: (json: any): PostTestRequestContentRequiredCompositeNull => {
|
|
351
|
+
if (json === undefined || json === null) {
|
|
352
|
+
return json;
|
|
353
|
+
}
|
|
354
|
+
if (typeof json === 'string') {
|
|
355
|
+
return json;
|
|
356
|
+
}
|
|
357
|
+
return json;
|
|
358
|
+
},
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Client configuration for TestApi
|
|
364
|
+
*/
|
|
365
|
+
export interface TestApiConfig {
|
|
366
|
+
/**
|
|
367
|
+
* Base URL for the API
|
|
368
|
+
*/
|
|
369
|
+
url: string;
|
|
370
|
+
/**
|
|
371
|
+
* Custom instance of fetch. By default the global 'fetch' is used.
|
|
372
|
+
* You can override this to add custom middleware for use cases such as adding authentication headers.
|
|
373
|
+
*/
|
|
374
|
+
fetch?: typeof fetch;
|
|
375
|
+
/**
|
|
376
|
+
* Additional configuration
|
|
377
|
+
*/
|
|
378
|
+
options?: {
|
|
379
|
+
/**
|
|
380
|
+
* By default, the client will add a Content-Type header, set to the media type defined for
|
|
381
|
+
* the request in the OpenAPI specification.
|
|
382
|
+
* Set this to false to omit this header.
|
|
383
|
+
*/
|
|
384
|
+
omitContentTypeHeader?: boolean;
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/**
|
|
389
|
+
* API Client for TestApi
|
|
390
|
+
*/
|
|
391
|
+
export class TestApi {
|
|
392
|
+
private $config: TestApiConfig;
|
|
393
|
+
|
|
394
|
+
constructor(config: TestApiConfig) {
|
|
395
|
+
this.$config = config;
|
|
396
|
+
|
|
397
|
+
this.postTest = this.postTest.bind(this);
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
private $url = (
|
|
401
|
+
path: string,
|
|
402
|
+
pathParameters: { [key: string]: any },
|
|
403
|
+
queryParameters: { [key: string]: any },
|
|
404
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
405
|
+
): string => {
|
|
406
|
+
const baseUrl = this.$config.url.endsWith('/')
|
|
407
|
+
? this.$config.url.slice(0, -1)
|
|
408
|
+
: this.$config.url;
|
|
409
|
+
const pathWithParameters = Object.entries(pathParameters).reduce(
|
|
410
|
+
(withParams, [key, value]) =>
|
|
411
|
+
withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
|
|
412
|
+
path,
|
|
413
|
+
);
|
|
414
|
+
const queryString = Object.entries(queryParameters)
|
|
415
|
+
.map(([key, value]) => {
|
|
416
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
417
|
+
return value
|
|
418
|
+
.map(
|
|
419
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
420
|
+
)
|
|
421
|
+
.join('&');
|
|
422
|
+
}
|
|
423
|
+
return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
|
|
424
|
+
})
|
|
425
|
+
.join('&');
|
|
426
|
+
return (
|
|
427
|
+
baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
|
|
428
|
+
);
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
private $headers = (
|
|
432
|
+
headerParameters: { [key: string]: any },
|
|
433
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
434
|
+
): [string, string][] => {
|
|
435
|
+
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
436
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
437
|
+
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
438
|
+
}
|
|
439
|
+
return [[key, String(value)]];
|
|
440
|
+
});
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
private $fetch: typeof fetch = (...args) =>
|
|
444
|
+
(this.$config.fetch ?? fetch)(...args);
|
|
445
|
+
|
|
446
|
+
public async postTest(input: PostTestRequest): Promise<PostTest200Response> {
|
|
447
|
+
const pathParameters: { [key: string]: any } = {};
|
|
448
|
+
const queryParameters: { [key: string]: any } = {};
|
|
449
|
+
const headerParameters: { [key: string]: any } = {};
|
|
450
|
+
if (!this.$config.options?.omitContentTypeHeader) {
|
|
451
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
452
|
+
}
|
|
453
|
+
const body =
|
|
454
|
+
typeof input === 'object'
|
|
455
|
+
? JSON.stringify($IO.PostTestRequestContent.toJson(input))
|
|
456
|
+
: String($IO.PostTestRequestContent.toJson(input));
|
|
457
|
+
|
|
458
|
+
const response = await this.$fetch(
|
|
459
|
+
this.$url('/test', pathParameters, queryParameters),
|
|
460
|
+
{
|
|
461
|
+
headers: this.$headers(headerParameters),
|
|
462
|
+
method: 'POST',
|
|
463
|
+
body,
|
|
464
|
+
},
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
if (response.status === 200) {
|
|
468
|
+
return $IO.PostTest200Response.fromJson(await response.json());
|
|
469
|
+
}
|
|
470
|
+
throw new Error(
|
|
471
|
+
\`Unknown response status \${response.status} returned by API\`,
|
|
472
|
+
);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
"
|
|
476
|
+
`;
|
|
477
|
+
|
|
478
|
+
exports[`openApiTsClientGenerator - primitive types > should handle date and date-time formats 1`] = `
|
|
479
|
+
"export type PostDates200Response = {
|
|
480
|
+
processedDate?: Date;
|
|
481
|
+
processedDateTime?: Date;
|
|
482
|
+
};
|
|
483
|
+
export type PostDatesRequestContent = {
|
|
484
|
+
dateOnly: Date;
|
|
485
|
+
dateTime: Date;
|
|
486
|
+
dateArray?: Array<Date>;
|
|
487
|
+
dateTimeArray?: Array<Date>;
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
export type PostDatesRequest = PostDatesRequestContent | undefined;
|
|
491
|
+
export type PostDatesError = never;
|
|
492
|
+
|
|
493
|
+
export type PostSingleDateRequest = Date;
|
|
494
|
+
export type PostSingleDateError = never;
|
|
495
|
+
"
|
|
496
|
+
`;
|
|
497
|
+
|
|
498
|
+
exports[`openApiTsClientGenerator - primitive types > should handle date and date-time formats 2`] = `
|
|
499
|
+
"import type {
|
|
500
|
+
PostDates200Response,
|
|
501
|
+
PostDatesRequestContent,
|
|
502
|
+
PostDatesRequest,
|
|
503
|
+
PostSingleDateRequest,
|
|
504
|
+
} from './types.gen.js';
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Utility for serialisation and deserialisation of API types.
|
|
508
|
+
*/
|
|
509
|
+
export class $IO {
|
|
510
|
+
protected static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
511
|
+
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
512
|
+
|
|
513
|
+
public static PostDates200Response = {
|
|
514
|
+
toJson: (model: PostDates200Response): any => {
|
|
515
|
+
if (model === undefined || model === null) {
|
|
516
|
+
return model;
|
|
517
|
+
}
|
|
518
|
+
return {
|
|
519
|
+
...(model.processedDate === undefined
|
|
520
|
+
? {}
|
|
521
|
+
: {
|
|
522
|
+
processedDate: model.processedDate.toISOString().slice(0, 10),
|
|
523
|
+
}),
|
|
524
|
+
...(model.processedDateTime === undefined
|
|
525
|
+
? {}
|
|
526
|
+
: {
|
|
527
|
+
processedDateTime: model.processedDateTime.toISOString(),
|
|
528
|
+
}),
|
|
529
|
+
};
|
|
530
|
+
},
|
|
531
|
+
fromJson: (json: any): PostDates200Response => {
|
|
532
|
+
if (json === undefined || json === null) {
|
|
533
|
+
return json;
|
|
534
|
+
}
|
|
535
|
+
return {
|
|
536
|
+
...(json['processedDate'] === undefined
|
|
537
|
+
? {}
|
|
538
|
+
: {
|
|
539
|
+
processedDate: new Date(json['processedDate']),
|
|
540
|
+
}),
|
|
541
|
+
...(json['processedDateTime'] === undefined
|
|
542
|
+
? {}
|
|
543
|
+
: {
|
|
544
|
+
processedDateTime: new Date(json['processedDateTime']),
|
|
545
|
+
}),
|
|
546
|
+
};
|
|
547
|
+
},
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
public static PostDatesRequestContent = {
|
|
551
|
+
toJson: (model: PostDatesRequestContent): any => {
|
|
552
|
+
if (model === undefined || model === null) {
|
|
553
|
+
return model;
|
|
554
|
+
}
|
|
555
|
+
return {
|
|
556
|
+
...(model.dateOnly === undefined
|
|
557
|
+
? {}
|
|
558
|
+
: {
|
|
559
|
+
dateOnly: model.dateOnly.toISOString().slice(0, 10),
|
|
560
|
+
}),
|
|
561
|
+
...(model.dateTime === undefined
|
|
562
|
+
? {}
|
|
563
|
+
: {
|
|
564
|
+
dateTime: model.dateTime.toISOString(),
|
|
565
|
+
}),
|
|
566
|
+
...(model.dateArray === undefined
|
|
567
|
+
? {}
|
|
568
|
+
: {
|
|
569
|
+
dateArray: model.dateArray.map((item0) =>
|
|
570
|
+
item0.toISOString().slice(0, 10),
|
|
571
|
+
),
|
|
572
|
+
}),
|
|
573
|
+
...(model.dateTimeArray === undefined
|
|
574
|
+
? {}
|
|
575
|
+
: {
|
|
576
|
+
dateTimeArray: model.dateTimeArray.map((item0) =>
|
|
577
|
+
item0.toISOString(),
|
|
578
|
+
),
|
|
579
|
+
}),
|
|
580
|
+
};
|
|
581
|
+
},
|
|
582
|
+
fromJson: (json: any): PostDatesRequestContent => {
|
|
583
|
+
if (json === undefined || json === null) {
|
|
584
|
+
return json;
|
|
585
|
+
}
|
|
586
|
+
return {
|
|
587
|
+
dateOnly: new Date(json['dateOnly']),
|
|
588
|
+
dateTime: new Date(json['dateTime']),
|
|
589
|
+
...(json['dateArray'] === undefined
|
|
590
|
+
? {}
|
|
591
|
+
: {
|
|
592
|
+
dateArray: (json['dateArray'] as Array<any>).map(
|
|
593
|
+
(item0) => new Date(item0),
|
|
594
|
+
),
|
|
595
|
+
}),
|
|
596
|
+
...(json['dateTimeArray'] === undefined
|
|
597
|
+
? {}
|
|
598
|
+
: {
|
|
599
|
+
dateTimeArray: (json['dateTimeArray'] as Array<any>).map(
|
|
600
|
+
(item0) => new Date(item0),
|
|
601
|
+
),
|
|
602
|
+
}),
|
|
603
|
+
};
|
|
604
|
+
},
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/**
|
|
609
|
+
* Client configuration for TestApi
|
|
610
|
+
*/
|
|
611
|
+
export interface TestApiConfig {
|
|
612
|
+
/**
|
|
613
|
+
* Base URL for the API
|
|
614
|
+
*/
|
|
615
|
+
url: string;
|
|
616
|
+
/**
|
|
617
|
+
* Custom instance of fetch. By default the global 'fetch' is used.
|
|
618
|
+
* You can override this to add custom middleware for use cases such as adding authentication headers.
|
|
619
|
+
*/
|
|
620
|
+
fetch?: typeof fetch;
|
|
621
|
+
/**
|
|
622
|
+
* Additional configuration
|
|
623
|
+
*/
|
|
624
|
+
options?: {
|
|
625
|
+
/**
|
|
626
|
+
* By default, the client will add a Content-Type header, set to the media type defined for
|
|
627
|
+
* the request in the OpenAPI specification.
|
|
628
|
+
* Set this to false to omit this header.
|
|
629
|
+
*/
|
|
630
|
+
omitContentTypeHeader?: boolean;
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* API Client for TestApi
|
|
636
|
+
*/
|
|
637
|
+
export class TestApi {
|
|
638
|
+
private $config: TestApiConfig;
|
|
639
|
+
|
|
640
|
+
constructor(config: TestApiConfig) {
|
|
641
|
+
this.$config = config;
|
|
642
|
+
|
|
643
|
+
this.postDates = this.postDates.bind(this);
|
|
644
|
+
this.postSingleDate = this.postSingleDate.bind(this);
|
|
645
|
+
}
|
|
646
|
+
|
|
647
|
+
private $url = (
|
|
648
|
+
path: string,
|
|
649
|
+
pathParameters: { [key: string]: any },
|
|
650
|
+
queryParameters: { [key: string]: any },
|
|
651
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
652
|
+
): string => {
|
|
653
|
+
const baseUrl = this.$config.url.endsWith('/')
|
|
654
|
+
? this.$config.url.slice(0, -1)
|
|
655
|
+
: this.$config.url;
|
|
656
|
+
const pathWithParameters = Object.entries(pathParameters).reduce(
|
|
657
|
+
(withParams, [key, value]) =>
|
|
658
|
+
withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
|
|
659
|
+
path,
|
|
660
|
+
);
|
|
661
|
+
const queryString = Object.entries(queryParameters)
|
|
662
|
+
.map(([key, value]) => {
|
|
663
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
664
|
+
return value
|
|
665
|
+
.map(
|
|
666
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
667
|
+
)
|
|
668
|
+
.join('&');
|
|
669
|
+
}
|
|
670
|
+
return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
|
|
671
|
+
})
|
|
672
|
+
.join('&');
|
|
673
|
+
return (
|
|
674
|
+
baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
|
|
675
|
+
);
|
|
676
|
+
};
|
|
677
|
+
|
|
678
|
+
private $headers = (
|
|
679
|
+
headerParameters: { [key: string]: any },
|
|
680
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
681
|
+
): [string, string][] => {
|
|
682
|
+
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
683
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
684
|
+
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
685
|
+
}
|
|
686
|
+
return [[key, String(value)]];
|
|
687
|
+
});
|
|
688
|
+
};
|
|
689
|
+
|
|
690
|
+
private $fetch: typeof fetch = (...args) =>
|
|
691
|
+
(this.$config.fetch ?? fetch)(...args);
|
|
692
|
+
|
|
693
|
+
public async postDates(
|
|
694
|
+
input?: PostDatesRequest,
|
|
695
|
+
): Promise<PostDates200Response> {
|
|
696
|
+
const pathParameters: { [key: string]: any } = {};
|
|
697
|
+
const queryParameters: { [key: string]: any } = {};
|
|
698
|
+
const headerParameters: { [key: string]: any } = {};
|
|
699
|
+
if (!this.$config.options?.omitContentTypeHeader) {
|
|
700
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
701
|
+
}
|
|
702
|
+
const body =
|
|
703
|
+
input === undefined
|
|
704
|
+
? undefined
|
|
705
|
+
: typeof input === 'object'
|
|
706
|
+
? JSON.stringify($IO.PostDatesRequestContent.toJson(input))
|
|
707
|
+
: String($IO.PostDatesRequestContent.toJson(input));
|
|
708
|
+
|
|
709
|
+
const response = await this.$fetch(
|
|
710
|
+
this.$url('/dates', pathParameters, queryParameters),
|
|
711
|
+
{
|
|
712
|
+
headers: this.$headers(headerParameters),
|
|
713
|
+
method: 'POST',
|
|
714
|
+
body,
|
|
715
|
+
},
|
|
716
|
+
);
|
|
717
|
+
|
|
718
|
+
if (response.status === 200) {
|
|
719
|
+
return $IO.PostDates200Response.fromJson(await response.json());
|
|
720
|
+
}
|
|
721
|
+
throw new Error(
|
|
722
|
+
\`Unknown response status \${response.status} returned by API\`,
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
public async postSingleDate(input: PostSingleDateRequest): Promise<Date> {
|
|
727
|
+
const pathParameters: { [key: string]: any } = {};
|
|
728
|
+
const queryParameters: { [key: string]: any } = {};
|
|
729
|
+
const headerParameters: { [key: string]: any } = {};
|
|
730
|
+
if (!this.$config.options?.omitContentTypeHeader) {
|
|
731
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
732
|
+
}
|
|
733
|
+
const body = input.toISOString().slice(0, 10);
|
|
734
|
+
|
|
735
|
+
const response = await this.$fetch(
|
|
736
|
+
this.$url('/single-date', pathParameters, queryParameters),
|
|
737
|
+
{
|
|
738
|
+
headers: this.$headers(headerParameters),
|
|
739
|
+
method: 'POST',
|
|
740
|
+
body,
|
|
741
|
+
},
|
|
742
|
+
);
|
|
743
|
+
|
|
744
|
+
if (response.status === 200) {
|
|
745
|
+
return new Date(await response.text());
|
|
746
|
+
}
|
|
747
|
+
throw new Error(
|
|
748
|
+
\`Unknown response status \${response.status} returned by API\`,
|
|
749
|
+
);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
"
|
|
753
|
+
`;
|
|
754
|
+
|
|
755
|
+
exports[`openApiTsClientGenerator - primitive types > should handle enum request and response bodies 1`] = `
|
|
756
|
+
"export type UpdateStatus200Response = 'accepted' | 'rejected';
|
|
757
|
+
export type UpdateStatusRequestContent =
|
|
758
|
+
| 'pending'
|
|
759
|
+
| 'in_progress'
|
|
760
|
+
| 'completed'
|
|
761
|
+
| 'failed';
|
|
762
|
+
|
|
763
|
+
export type UpdateStatusRequest = UpdateStatusRequestContent;
|
|
764
|
+
export type UpdateStatusError = never;
|
|
765
|
+
"
|
|
766
|
+
`;
|
|
767
|
+
|
|
768
|
+
exports[`openApiTsClientGenerator - primitive types > should handle enum request and response bodies 2`] = `
|
|
769
|
+
"import type {
|
|
770
|
+
UpdateStatus200Response,
|
|
771
|
+
UpdateStatusRequestContent,
|
|
772
|
+
UpdateStatusRequest,
|
|
773
|
+
} from './types.gen.js';
|
|
774
|
+
|
|
775
|
+
/**
|
|
776
|
+
* Utility for serialisation and deserialisation of API types.
|
|
777
|
+
*/
|
|
778
|
+
export class $IO {
|
|
779
|
+
protected static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
780
|
+
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
781
|
+
}
|
|
782
|
+
|
|
783
|
+
/**
|
|
784
|
+
* Client configuration for TestApi
|
|
785
|
+
*/
|
|
786
|
+
export interface TestApiConfig {
|
|
787
|
+
/**
|
|
788
|
+
* Base URL for the API
|
|
789
|
+
*/
|
|
790
|
+
url: string;
|
|
791
|
+
/**
|
|
792
|
+
* Custom instance of fetch. By default the global 'fetch' is used.
|
|
793
|
+
* You can override this to add custom middleware for use cases such as adding authentication headers.
|
|
794
|
+
*/
|
|
795
|
+
fetch?: typeof fetch;
|
|
796
|
+
/**
|
|
797
|
+
* Additional configuration
|
|
798
|
+
*/
|
|
799
|
+
options?: {
|
|
800
|
+
/**
|
|
801
|
+
* By default, the client will add a Content-Type header, set to the media type defined for
|
|
802
|
+
* the request in the OpenAPI specification.
|
|
803
|
+
* Set this to false to omit this header.
|
|
804
|
+
*/
|
|
805
|
+
omitContentTypeHeader?: boolean;
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* API Client for TestApi
|
|
811
|
+
*/
|
|
812
|
+
export class TestApi {
|
|
813
|
+
private $config: TestApiConfig;
|
|
814
|
+
|
|
815
|
+
constructor(config: TestApiConfig) {
|
|
816
|
+
this.$config = config;
|
|
817
|
+
|
|
818
|
+
this.updateStatus = this.updateStatus.bind(this);
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
private $url = (
|
|
822
|
+
path: string,
|
|
823
|
+
pathParameters: { [key: string]: any },
|
|
824
|
+
queryParameters: { [key: string]: any },
|
|
825
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
826
|
+
): string => {
|
|
827
|
+
const baseUrl = this.$config.url.endsWith('/')
|
|
828
|
+
? this.$config.url.slice(0, -1)
|
|
829
|
+
: this.$config.url;
|
|
830
|
+
const pathWithParameters = Object.entries(pathParameters).reduce(
|
|
831
|
+
(withParams, [key, value]) =>
|
|
832
|
+
withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
|
|
833
|
+
path,
|
|
834
|
+
);
|
|
835
|
+
const queryString = Object.entries(queryParameters)
|
|
836
|
+
.map(([key, value]) => {
|
|
837
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
838
|
+
return value
|
|
839
|
+
.map(
|
|
840
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
841
|
+
)
|
|
842
|
+
.join('&');
|
|
843
|
+
}
|
|
844
|
+
return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
|
|
845
|
+
})
|
|
846
|
+
.join('&');
|
|
847
|
+
return (
|
|
848
|
+
baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
|
|
849
|
+
);
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
private $headers = (
|
|
853
|
+
headerParameters: { [key: string]: any },
|
|
854
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
855
|
+
): [string, string][] => {
|
|
856
|
+
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
857
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
858
|
+
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
859
|
+
}
|
|
860
|
+
return [[key, String(value)]];
|
|
861
|
+
});
|
|
862
|
+
};
|
|
863
|
+
|
|
864
|
+
private $fetch: typeof fetch = (...args) =>
|
|
865
|
+
(this.$config.fetch ?? fetch)(...args);
|
|
866
|
+
|
|
867
|
+
public async updateStatus(
|
|
868
|
+
input: UpdateStatusRequest,
|
|
869
|
+
): Promise<UpdateStatus200Response> {
|
|
870
|
+
const pathParameters: { [key: string]: any } = {};
|
|
871
|
+
const queryParameters: { [key: string]: any } = {};
|
|
872
|
+
const headerParameters: { [key: string]: any } = {};
|
|
873
|
+
if (!this.$config.options?.omitContentTypeHeader) {
|
|
874
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
875
|
+
}
|
|
876
|
+
const body = input;
|
|
877
|
+
|
|
878
|
+
const response = await this.$fetch(
|
|
879
|
+
this.$url('/status', pathParameters, queryParameters),
|
|
880
|
+
{
|
|
881
|
+
headers: this.$headers(headerParameters),
|
|
882
|
+
method: 'POST',
|
|
883
|
+
body,
|
|
884
|
+
},
|
|
885
|
+
);
|
|
886
|
+
|
|
887
|
+
if (response.status === 200) {
|
|
888
|
+
return (await response.text()) as UpdateStatus200Response;
|
|
889
|
+
}
|
|
890
|
+
throw new Error(
|
|
891
|
+
\`Unknown response status \${response.status} returned by API\`,
|
|
892
|
+
);
|
|
893
|
+
}
|
|
894
|
+
}
|
|
895
|
+
"
|
|
896
|
+
`;
|
|
897
|
+
|
|
898
|
+
exports[`openApiTsClientGenerator - primitive types > should handle number and string constraints 1`] = `
|
|
899
|
+
"export type TestConstraints200Response = {
|
|
900
|
+
result?: string;
|
|
901
|
+
};
|
|
902
|
+
export type TestConstraintsRequestContent = {
|
|
903
|
+
constrainedInt: number;
|
|
904
|
+
constrainedString: string;
|
|
905
|
+
hostname?: string;
|
|
906
|
+
ipv4?: string;
|
|
907
|
+
ipv6?: string;
|
|
908
|
+
uri?: string;
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
export type TestConstraintsRequest = TestConstraintsRequestContent | undefined;
|
|
912
|
+
export type TestConstraintsError = never;
|
|
913
|
+
"
|
|
914
|
+
`;
|
|
915
|
+
|
|
916
|
+
exports[`openApiTsClientGenerator - primitive types > should handle number and string constraints 2`] = `
|
|
917
|
+
"import type {
|
|
918
|
+
TestConstraints200Response,
|
|
919
|
+
TestConstraintsRequestContent,
|
|
920
|
+
TestConstraintsRequest,
|
|
921
|
+
} from './types.gen.js';
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* Utility for serialisation and deserialisation of API types.
|
|
925
|
+
*/
|
|
926
|
+
export class $IO {
|
|
927
|
+
protected static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
928
|
+
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
929
|
+
|
|
930
|
+
public static TestConstraints200Response = {
|
|
931
|
+
toJson: (model: TestConstraints200Response): any => {
|
|
932
|
+
if (model === undefined || model === null) {
|
|
933
|
+
return model;
|
|
934
|
+
}
|
|
935
|
+
return {
|
|
936
|
+
...(model.result === undefined
|
|
937
|
+
? {}
|
|
938
|
+
: {
|
|
939
|
+
result: model.result,
|
|
940
|
+
}),
|
|
941
|
+
};
|
|
942
|
+
},
|
|
943
|
+
fromJson: (json: any): TestConstraints200Response => {
|
|
944
|
+
if (json === undefined || json === null) {
|
|
945
|
+
return json;
|
|
946
|
+
}
|
|
947
|
+
return {
|
|
948
|
+
...(json['result'] === undefined
|
|
949
|
+
? {}
|
|
950
|
+
: {
|
|
951
|
+
result: json['result'],
|
|
952
|
+
}),
|
|
953
|
+
};
|
|
954
|
+
},
|
|
955
|
+
};
|
|
956
|
+
|
|
957
|
+
public static TestConstraintsRequestContent = {
|
|
958
|
+
toJson: (model: TestConstraintsRequestContent): any => {
|
|
959
|
+
if (model === undefined || model === null) {
|
|
960
|
+
return model;
|
|
961
|
+
}
|
|
962
|
+
return {
|
|
963
|
+
...(model.constrainedInt === undefined
|
|
964
|
+
? {}
|
|
965
|
+
: {
|
|
966
|
+
constrainedInt: model.constrainedInt,
|
|
967
|
+
}),
|
|
968
|
+
...(model.constrainedString === undefined
|
|
969
|
+
? {}
|
|
970
|
+
: {
|
|
971
|
+
constrainedString: model.constrainedString,
|
|
972
|
+
}),
|
|
973
|
+
...(model.hostname === undefined
|
|
974
|
+
? {}
|
|
975
|
+
: {
|
|
976
|
+
hostname: model.hostname,
|
|
977
|
+
}),
|
|
978
|
+
...(model.ipv4 === undefined
|
|
979
|
+
? {}
|
|
980
|
+
: {
|
|
981
|
+
ipv4: model.ipv4,
|
|
982
|
+
}),
|
|
983
|
+
...(model.ipv6 === undefined
|
|
984
|
+
? {}
|
|
985
|
+
: {
|
|
986
|
+
ipv6: model.ipv6,
|
|
987
|
+
}),
|
|
988
|
+
...(model.uri === undefined
|
|
989
|
+
? {}
|
|
990
|
+
: {
|
|
991
|
+
uri: model.uri,
|
|
992
|
+
}),
|
|
993
|
+
};
|
|
994
|
+
},
|
|
995
|
+
fromJson: (json: any): TestConstraintsRequestContent => {
|
|
996
|
+
if (json === undefined || json === null) {
|
|
997
|
+
return json;
|
|
998
|
+
}
|
|
999
|
+
return {
|
|
1000
|
+
constrainedInt: json['constrainedInt'],
|
|
1001
|
+
constrainedString: json['constrainedString'],
|
|
1002
|
+
...(json['hostname'] === undefined
|
|
1003
|
+
? {}
|
|
1004
|
+
: {
|
|
1005
|
+
hostname: json['hostname'],
|
|
1006
|
+
}),
|
|
1007
|
+
...(json['ipv4'] === undefined
|
|
1008
|
+
? {}
|
|
1009
|
+
: {
|
|
1010
|
+
ipv4: json['ipv4'],
|
|
1011
|
+
}),
|
|
1012
|
+
...(json['ipv6'] === undefined
|
|
1013
|
+
? {}
|
|
1014
|
+
: {
|
|
1015
|
+
ipv6: json['ipv6'],
|
|
1016
|
+
}),
|
|
1017
|
+
...(json['uri'] === undefined
|
|
1018
|
+
? {}
|
|
1019
|
+
: {
|
|
1020
|
+
uri: json['uri'],
|
|
1021
|
+
}),
|
|
1022
|
+
};
|
|
1023
|
+
},
|
|
1024
|
+
};
|
|
1025
|
+
}
|
|
1026
|
+
|
|
1027
|
+
/**
|
|
1028
|
+
* Client configuration for TestApi
|
|
1029
|
+
*/
|
|
1030
|
+
export interface TestApiConfig {
|
|
1031
|
+
/**
|
|
1032
|
+
* Base URL for the API
|
|
1033
|
+
*/
|
|
1034
|
+
url: string;
|
|
1035
|
+
/**
|
|
1036
|
+
* Custom instance of fetch. By default the global 'fetch' is used.
|
|
1037
|
+
* You can override this to add custom middleware for use cases such as adding authentication headers.
|
|
1038
|
+
*/
|
|
1039
|
+
fetch?: typeof fetch;
|
|
1040
|
+
/**
|
|
1041
|
+
* Additional configuration
|
|
1042
|
+
*/
|
|
1043
|
+
options?: {
|
|
1044
|
+
/**
|
|
1045
|
+
* By default, the client will add a Content-Type header, set to the media type defined for
|
|
1046
|
+
* the request in the OpenAPI specification.
|
|
1047
|
+
* Set this to false to omit this header.
|
|
1048
|
+
*/
|
|
1049
|
+
omitContentTypeHeader?: boolean;
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
|
|
1053
|
+
/**
|
|
1054
|
+
* API Client for TestApi
|
|
1055
|
+
*/
|
|
1056
|
+
export class TestApi {
|
|
1057
|
+
private $config: TestApiConfig;
|
|
1058
|
+
|
|
1059
|
+
constructor(config: TestApiConfig) {
|
|
1060
|
+
this.$config = config;
|
|
1061
|
+
|
|
1062
|
+
this.testConstraints = this.testConstraints.bind(this);
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
private $url = (
|
|
1066
|
+
path: string,
|
|
1067
|
+
pathParameters: { [key: string]: any },
|
|
1068
|
+
queryParameters: { [key: string]: any },
|
|
1069
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
1070
|
+
): string => {
|
|
1071
|
+
const baseUrl = this.$config.url.endsWith('/')
|
|
1072
|
+
? this.$config.url.slice(0, -1)
|
|
1073
|
+
: this.$config.url;
|
|
1074
|
+
const pathWithParameters = Object.entries(pathParameters).reduce(
|
|
1075
|
+
(withParams, [key, value]) =>
|
|
1076
|
+
withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
|
|
1077
|
+
path,
|
|
1078
|
+
);
|
|
1079
|
+
const queryString = Object.entries(queryParameters)
|
|
1080
|
+
.map(([key, value]) => {
|
|
1081
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1082
|
+
return value
|
|
1083
|
+
.map(
|
|
1084
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
1085
|
+
)
|
|
1086
|
+
.join('&');
|
|
1087
|
+
}
|
|
1088
|
+
return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
|
|
1089
|
+
})
|
|
1090
|
+
.join('&');
|
|
1091
|
+
return (
|
|
1092
|
+
baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
|
|
1093
|
+
);
|
|
1094
|
+
};
|
|
1095
|
+
|
|
1096
|
+
private $headers = (
|
|
1097
|
+
headerParameters: { [key: string]: any },
|
|
1098
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
1099
|
+
): [string, string][] => {
|
|
1100
|
+
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
1101
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1102
|
+
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
1103
|
+
}
|
|
1104
|
+
return [[key, String(value)]];
|
|
1105
|
+
});
|
|
1106
|
+
};
|
|
1107
|
+
|
|
1108
|
+
private $fetch: typeof fetch = (...args) =>
|
|
1109
|
+
(this.$config.fetch ?? fetch)(...args);
|
|
1110
|
+
|
|
1111
|
+
public async testConstraints(
|
|
1112
|
+
input?: TestConstraintsRequest,
|
|
1113
|
+
): Promise<TestConstraints200Response> {
|
|
1114
|
+
const pathParameters: { [key: string]: any } = {};
|
|
1115
|
+
const queryParameters: { [key: string]: any } = {};
|
|
1116
|
+
const headerParameters: { [key: string]: any } = {};
|
|
1117
|
+
if (!this.$config.options?.omitContentTypeHeader) {
|
|
1118
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
1119
|
+
}
|
|
1120
|
+
const body =
|
|
1121
|
+
input === undefined
|
|
1122
|
+
? undefined
|
|
1123
|
+
: typeof input === 'object'
|
|
1124
|
+
? JSON.stringify($IO.TestConstraintsRequestContent.toJson(input))
|
|
1125
|
+
: String($IO.TestConstraintsRequestContent.toJson(input));
|
|
1126
|
+
|
|
1127
|
+
const response = await this.$fetch(
|
|
1128
|
+
this.$url('/constraints', pathParameters, queryParameters),
|
|
1129
|
+
{
|
|
1130
|
+
headers: this.$headers(headerParameters),
|
|
1131
|
+
method: 'POST',
|
|
1132
|
+
body,
|
|
1133
|
+
},
|
|
1134
|
+
);
|
|
1135
|
+
|
|
1136
|
+
if (response.status === 200) {
|
|
1137
|
+
return $IO.TestConstraints200Response.fromJson(await response.json());
|
|
1138
|
+
}
|
|
1139
|
+
throw new Error(
|
|
1140
|
+
\`Unknown response status \${response.status} returned by API\`,
|
|
1141
|
+
);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
"
|
|
1145
|
+
`;
|
|
1146
|
+
|
|
1147
|
+
exports[`openApiTsClientGenerator - primitive types > should handle special formats and vendor extensions 1`] = `
|
|
1148
|
+
"export type PostTest200Response = {
|
|
1149
|
+
createdAt?: Date;
|
|
1150
|
+
};
|
|
1151
|
+
export type PostTestRequestContent = {
|
|
1152
|
+
int32?: number;
|
|
1153
|
+
int64?: number;
|
|
1154
|
+
float?: number;
|
|
1155
|
+
double?: number;
|
|
1156
|
+
binary?: Blob;
|
|
1157
|
+
byte?: string;
|
|
1158
|
+
uuid?: string;
|
|
1159
|
+
email?: string;
|
|
1160
|
+
};
|
|
1161
|
+
export type PostTestRequestQueryParameters = {
|
|
1162
|
+
date?: Date;
|
|
1163
|
+
timestamp?: Date;
|
|
1164
|
+
};
|
|
1165
|
+
|
|
1166
|
+
export type PostTestRequest = PostTestRequestQueryParameters &
|
|
1167
|
+
PostTestRequestContent;
|
|
1168
|
+
export type PostTestError = never;
|
|
1169
|
+
"
|
|
1170
|
+
`;
|
|
1171
|
+
|
|
1172
|
+
exports[`openApiTsClientGenerator - primitive types > should handle special formats and vendor extensions 2`] = `
|
|
1173
|
+
"import type {
|
|
1174
|
+
PostTest200Response,
|
|
1175
|
+
PostTestRequestContent,
|
|
1176
|
+
PostTestRequestQueryParameters,
|
|
1177
|
+
PostTestRequest,
|
|
1178
|
+
} from './types.gen.js';
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Utility for serialisation and deserialisation of API types.
|
|
1182
|
+
*/
|
|
1183
|
+
export class $IO {
|
|
1184
|
+
protected static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
1185
|
+
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
1186
|
+
|
|
1187
|
+
public static PostTest200Response = {
|
|
1188
|
+
toJson: (model: PostTest200Response): any => {
|
|
1189
|
+
if (model === undefined || model === null) {
|
|
1190
|
+
return model;
|
|
1191
|
+
}
|
|
1192
|
+
return {
|
|
1193
|
+
...(model.createdAt === undefined
|
|
1194
|
+
? {}
|
|
1195
|
+
: {
|
|
1196
|
+
createdAt: model.createdAt.toISOString(),
|
|
1197
|
+
}),
|
|
1198
|
+
};
|
|
1199
|
+
},
|
|
1200
|
+
fromJson: (json: any): PostTest200Response => {
|
|
1201
|
+
if (json === undefined || json === null) {
|
|
1202
|
+
return json;
|
|
1203
|
+
}
|
|
1204
|
+
return {
|
|
1205
|
+
...(json['createdAt'] === undefined
|
|
1206
|
+
? {}
|
|
1207
|
+
: {
|
|
1208
|
+
createdAt: new Date(json['createdAt']),
|
|
1209
|
+
}),
|
|
1210
|
+
};
|
|
1211
|
+
},
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
public static PostTestRequestContent = {
|
|
1215
|
+
toJson: (model: PostTestRequestContent): any => {
|
|
1216
|
+
if (model === undefined || model === null) {
|
|
1217
|
+
return model;
|
|
1218
|
+
}
|
|
1219
|
+
return {
|
|
1220
|
+
...(model.int32 === undefined
|
|
1221
|
+
? {}
|
|
1222
|
+
: {
|
|
1223
|
+
int32: model.int32,
|
|
1224
|
+
}),
|
|
1225
|
+
...(model.int64 === undefined
|
|
1226
|
+
? {}
|
|
1227
|
+
: {
|
|
1228
|
+
int64: model.int64,
|
|
1229
|
+
}),
|
|
1230
|
+
...(model.float === undefined
|
|
1231
|
+
? {}
|
|
1232
|
+
: {
|
|
1233
|
+
float: model.float,
|
|
1234
|
+
}),
|
|
1235
|
+
...(model.double === undefined
|
|
1236
|
+
? {}
|
|
1237
|
+
: {
|
|
1238
|
+
double: model.double,
|
|
1239
|
+
}),
|
|
1240
|
+
...(model.binary === undefined
|
|
1241
|
+
? {}
|
|
1242
|
+
: {
|
|
1243
|
+
binary: model.binary,
|
|
1244
|
+
}),
|
|
1245
|
+
...(model.byte === undefined
|
|
1246
|
+
? {}
|
|
1247
|
+
: {
|
|
1248
|
+
byte: model.byte,
|
|
1249
|
+
}),
|
|
1250
|
+
...(model.uuid === undefined
|
|
1251
|
+
? {}
|
|
1252
|
+
: {
|
|
1253
|
+
uuid: model.uuid,
|
|
1254
|
+
}),
|
|
1255
|
+
...(model.email === undefined
|
|
1256
|
+
? {}
|
|
1257
|
+
: {
|
|
1258
|
+
email: model.email,
|
|
1259
|
+
}),
|
|
1260
|
+
};
|
|
1261
|
+
},
|
|
1262
|
+
fromJson: (json: any): PostTestRequestContent => {
|
|
1263
|
+
if (json === undefined || json === null) {
|
|
1264
|
+
return json;
|
|
1265
|
+
}
|
|
1266
|
+
return {
|
|
1267
|
+
...(json['int32'] === undefined
|
|
1268
|
+
? {}
|
|
1269
|
+
: {
|
|
1270
|
+
int32: json['int32'],
|
|
1271
|
+
}),
|
|
1272
|
+
...(json['int64'] === undefined
|
|
1273
|
+
? {}
|
|
1274
|
+
: {
|
|
1275
|
+
int64: json['int64'],
|
|
1276
|
+
}),
|
|
1277
|
+
...(json['float'] === undefined
|
|
1278
|
+
? {}
|
|
1279
|
+
: {
|
|
1280
|
+
float: json['float'],
|
|
1281
|
+
}),
|
|
1282
|
+
...(json['double'] === undefined
|
|
1283
|
+
? {}
|
|
1284
|
+
: {
|
|
1285
|
+
double: json['double'],
|
|
1286
|
+
}),
|
|
1287
|
+
...(json['binary'] === undefined
|
|
1288
|
+
? {}
|
|
1289
|
+
: {
|
|
1290
|
+
binary: json['binary'],
|
|
1291
|
+
}),
|
|
1292
|
+
...(json['byte'] === undefined
|
|
1293
|
+
? {}
|
|
1294
|
+
: {
|
|
1295
|
+
byte: json['byte'],
|
|
1296
|
+
}),
|
|
1297
|
+
...(json['uuid'] === undefined
|
|
1298
|
+
? {}
|
|
1299
|
+
: {
|
|
1300
|
+
uuid: json['uuid'],
|
|
1301
|
+
}),
|
|
1302
|
+
...(json['email'] === undefined
|
|
1303
|
+
? {}
|
|
1304
|
+
: {
|
|
1305
|
+
email: json['email'],
|
|
1306
|
+
}),
|
|
1307
|
+
};
|
|
1308
|
+
},
|
|
1309
|
+
};
|
|
1310
|
+
|
|
1311
|
+
public static PostTestRequestQueryParameters = {
|
|
1312
|
+
toJson: (model: PostTestRequestQueryParameters): any => {
|
|
1313
|
+
if (model === undefined || model === null) {
|
|
1314
|
+
return model;
|
|
1315
|
+
}
|
|
1316
|
+
return {
|
|
1317
|
+
...(model.date === undefined
|
|
1318
|
+
? {}
|
|
1319
|
+
: {
|
|
1320
|
+
date: model.date.toISOString().slice(0, 10),
|
|
1321
|
+
}),
|
|
1322
|
+
...(model.timestamp === undefined
|
|
1323
|
+
? {}
|
|
1324
|
+
: {
|
|
1325
|
+
timestamp: model.timestamp.toISOString(),
|
|
1326
|
+
}),
|
|
1327
|
+
};
|
|
1328
|
+
},
|
|
1329
|
+
fromJson: (json: any): PostTestRequestQueryParameters => {
|
|
1330
|
+
if (json === undefined || json === null) {
|
|
1331
|
+
return json;
|
|
1332
|
+
}
|
|
1333
|
+
return {
|
|
1334
|
+
...(json['date'] === undefined
|
|
1335
|
+
? {}
|
|
1336
|
+
: {
|
|
1337
|
+
date: new Date(json['date']),
|
|
1338
|
+
}),
|
|
1339
|
+
...(json['timestamp'] === undefined
|
|
1340
|
+
? {}
|
|
1341
|
+
: {
|
|
1342
|
+
timestamp: new Date(json['timestamp']),
|
|
1343
|
+
}),
|
|
1344
|
+
};
|
|
1345
|
+
},
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
/**
|
|
1350
|
+
* Client configuration for TestApi
|
|
1351
|
+
*/
|
|
1352
|
+
export interface TestApiConfig {
|
|
1353
|
+
/**
|
|
1354
|
+
* Base URL for the API
|
|
1355
|
+
*/
|
|
1356
|
+
url: string;
|
|
1357
|
+
/**
|
|
1358
|
+
* Custom instance of fetch. By default the global 'fetch' is used.
|
|
1359
|
+
* You can override this to add custom middleware for use cases such as adding authentication headers.
|
|
1360
|
+
*/
|
|
1361
|
+
fetch?: typeof fetch;
|
|
1362
|
+
/**
|
|
1363
|
+
* Additional configuration
|
|
1364
|
+
*/
|
|
1365
|
+
options?: {
|
|
1366
|
+
/**
|
|
1367
|
+
* By default, the client will add a Content-Type header, set to the media type defined for
|
|
1368
|
+
* the request in the OpenAPI specification.
|
|
1369
|
+
* Set this to false to omit this header.
|
|
1370
|
+
*/
|
|
1371
|
+
omitContentTypeHeader?: boolean;
|
|
1372
|
+
};
|
|
1373
|
+
}
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* API Client for TestApi
|
|
1377
|
+
*/
|
|
1378
|
+
export class TestApi {
|
|
1379
|
+
private $config: TestApiConfig;
|
|
1380
|
+
|
|
1381
|
+
constructor(config: TestApiConfig) {
|
|
1382
|
+
this.$config = config;
|
|
1383
|
+
|
|
1384
|
+
this.postTest = this.postTest.bind(this);
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
private $url = (
|
|
1388
|
+
path: string,
|
|
1389
|
+
pathParameters: { [key: string]: any },
|
|
1390
|
+
queryParameters: { [key: string]: any },
|
|
1391
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
1392
|
+
): string => {
|
|
1393
|
+
const baseUrl = this.$config.url.endsWith('/')
|
|
1394
|
+
? this.$config.url.slice(0, -1)
|
|
1395
|
+
: this.$config.url;
|
|
1396
|
+
const pathWithParameters = Object.entries(pathParameters).reduce(
|
|
1397
|
+
(withParams, [key, value]) =>
|
|
1398
|
+
withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
|
|
1399
|
+
path,
|
|
1400
|
+
);
|
|
1401
|
+
const queryString = Object.entries(queryParameters)
|
|
1402
|
+
.map(([key, value]) => {
|
|
1403
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1404
|
+
return value
|
|
1405
|
+
.map(
|
|
1406
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
1407
|
+
)
|
|
1408
|
+
.join('&');
|
|
1409
|
+
}
|
|
1410
|
+
return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
|
|
1411
|
+
})
|
|
1412
|
+
.join('&');
|
|
1413
|
+
return (
|
|
1414
|
+
baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
|
|
1415
|
+
);
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1418
|
+
private $headers = (
|
|
1419
|
+
headerParameters: { [key: string]: any },
|
|
1420
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
1421
|
+
): [string, string][] => {
|
|
1422
|
+
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
1423
|
+
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1424
|
+
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
1425
|
+
}
|
|
1426
|
+
return [[key, String(value)]];
|
|
1427
|
+
});
|
|
1428
|
+
};
|
|
1429
|
+
|
|
1430
|
+
private $fetch: typeof fetch = (...args) =>
|
|
1431
|
+
(this.$config.fetch ?? fetch)(...args);
|
|
1432
|
+
|
|
1433
|
+
public async postTest(input: PostTestRequest): Promise<PostTest200Response> {
|
|
1434
|
+
const pathParameters: { [key: string]: any } = {};
|
|
1435
|
+
const queryParameters: { [key: string]: any } =
|
|
1436
|
+
$IO.PostTestRequestQueryParameters.toJson(input);
|
|
1437
|
+
const headerParameters: { [key: string]: any } = {};
|
|
1438
|
+
if (!this.$config.options?.omitContentTypeHeader) {
|
|
1439
|
+
headerParameters['Content-Type'] = 'application/json';
|
|
1440
|
+
}
|
|
1441
|
+
const collectionFormats = {
|
|
1442
|
+
date: 'multi',
|
|
1443
|
+
timestamp: 'multi',
|
|
1444
|
+
} as const;
|
|
1445
|
+
const body =
|
|
1446
|
+
input === undefined
|
|
1447
|
+
? undefined
|
|
1448
|
+
: typeof input === 'object'
|
|
1449
|
+
? JSON.stringify($IO.PostTestRequestContent.toJson(input))
|
|
1450
|
+
: String($IO.PostTestRequestContent.toJson(input));
|
|
1451
|
+
|
|
1452
|
+
const response = await this.$fetch(
|
|
1453
|
+
this.$url('/test', pathParameters, queryParameters, collectionFormats),
|
|
1454
|
+
{
|
|
1455
|
+
headers: this.$headers(headerParameters, collectionFormats),
|
|
1456
|
+
method: 'POST',
|
|
1457
|
+
body,
|
|
1458
|
+
},
|
|
1459
|
+
);
|
|
1460
|
+
|
|
1461
|
+
if (response.status === 200) {
|
|
1462
|
+
return $IO.PostTest200Response.fromJson(await response.json());
|
|
1463
|
+
}
|
|
1464
|
+
throw new Error(
|
|
1465
|
+
\`Unknown response status \${response.status} returned by API\`,
|
|
1466
|
+
);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
"
|
|
1470
|
+
`;
|