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