@aws/nx-plugin 1.0.0-rc.30 → 1.0.0-rc.32
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/LICENSE-THIRD-PARTY +235 -1336
- package/README.md +1 -1
- package/package.json +1 -2
- package/src/mcp-server/tools/create-workspace-command.js +2 -2
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/open-api/ts-client/__snapshots__/generator.additional-properties.spec.ts.snap +147 -33
- package/src/open-api/ts-client/__snapshots__/generator.arrays.spec.ts.snap +308 -75
- package/src/open-api/ts-client/__snapshots__/generator.complex-types.spec.ts.snap +286 -62
- package/src/open-api/ts-client/__snapshots__/generator.composite-types.spec.ts.snap +674 -93
- package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +211 -36
- package/src/open-api/ts-client/__snapshots__/generator.duplicate-types.spec.ts.snap +196 -44
- package/src/open-api/ts-client/__snapshots__/generator.edge-cases.spec.ts.snap +5507 -0
- package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +219 -60
- package/src/open-api/ts-client/__snapshots__/generator.multipart.spec.ts.snap +280 -0
- package/src/open-api/ts-client/__snapshots__/generator.primitive-types.spec.ts.snap +351 -80
- package/src/open-api/ts-client/__snapshots__/generator.request.spec.ts.snap +170 -49
- package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +98 -22
- package/src/open-api/ts-client/__snapshots__/generator.response.spec.ts.snap +147 -33
- package/src/open-api/ts-client/__snapshots__/generator.streaming.spec.ts.snap +392 -88
- package/src/open-api/ts-client/__snapshots__/generator.tags.spec.ts.snap +196 -44
- package/src/open-api/ts-client/files/client.gen.ts.template +166 -19
- package/src/open-api/ts-client/files/types.gen.ts.template +4 -4
- package/src/open-api/ts-client/generator.js +1 -1
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-hooks/files/options-proxy.gen.ts.template +5 -0
- package/src/open-api/ts-hooks/generator.spec.tsx +70 -0
- package/src/open-api/utils/codegen-data/languages.d.ts +0 -6
- package/src/open-api/utils/codegen-data/languages.js +23 -18
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data/types.d.ts +240 -10
- package/src/open-api/utils/codegen-data/types.js +24 -1
- package/src/open-api/utils/codegen-data/types.js.map +1 -1
- package/src/open-api/utils/codegen-data.d.ts +2 -2
- package/src/open-api/utils/codegen-data.js +357 -617
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.js +167 -22
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parser.d.ts +55 -0
- package/src/open-api/utils/parser.js +754 -0
- package/src/open-api/utils/parser.js.map +1 -0
- package/src/open-api/utils/types.d.ts +18 -0
- package/src/open-api/utils/types.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +6 -6
- package/src/py/fast-api/__snapshots__/generator.terraform.spec.ts.snap +414 -6
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +276 -4
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +414 -6
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +0 -23
- package/src/ts/mcp-server/generator.js +10 -22
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +69 -1
- package/src/utils/mcp.js +1 -1
- package/src/utils/mcp.js.map +1 -1
- package/src/utils/names.d.ts +6 -0
- package/src/utils/names.js +6 -1
- package/src/utils/names.js.map +1 -1
- package/src/utils/versions.d.ts +5 -5
- package/src/utils/versions.js +4 -4
- package/src/utils/versions.js.map +1 -1
|
@@ -48,7 +48,7 @@ exports[`openApiTsClientGenerator - FastAPI > should generate valid TypeScript f
|
|
|
48
48
|
* Utility for serialisation and deserialisation of API types.
|
|
49
49
|
*/
|
|
50
50
|
export class $IO {
|
|
51
|
-
|
|
51
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
52
52
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
53
53
|
|
|
54
54
|
public static EchoOutput = {
|
|
@@ -185,7 +185,7 @@ export class $IO {
|
|
|
185
185
|
...(model.loc === undefined
|
|
186
186
|
? {}
|
|
187
187
|
: {
|
|
188
|
-
loc: model.loc.map(
|
|
188
|
+
loc: model.loc.map($IO.LocationItem.toJson),
|
|
189
189
|
}),
|
|
190
190
|
...(model.msg === undefined
|
|
191
191
|
? {}
|
|
@@ -204,7 +204,7 @@ export class $IO {
|
|
|
204
204
|
return json;
|
|
205
205
|
}
|
|
206
206
|
return {
|
|
207
|
-
loc: (json['loc'] as Array<any>).map(
|
|
207
|
+
loc: (json['loc'] as Array<any>).map($IO.LocationItem.fromJson),
|
|
208
208
|
msg: json['msg'],
|
|
209
209
|
type: json['type'],
|
|
210
210
|
};
|
|
@@ -250,11 +250,31 @@ export class TestApi {
|
|
|
250
250
|
this.echo = this.echo.bind(this);
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
254
|
+
csv: ',',
|
|
255
|
+
ssv: ' ',
|
|
256
|
+
pipes: '|',
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
260
|
+
if (value === undefined || value === null) {
|
|
261
|
+
return [];
|
|
262
|
+
}
|
|
263
|
+
if (typeof value !== 'object') {
|
|
264
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
265
|
+
}
|
|
266
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
267
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
|
|
253
271
|
private $url = (
|
|
254
272
|
path: string,
|
|
255
273
|
pathParameters: { [key: string]: any },
|
|
256
274
|
queryParameters: { [key: string]: any },
|
|
257
|
-
collectionFormats?: {
|
|
275
|
+
collectionFormats?: {
|
|
276
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
277
|
+
},
|
|
258
278
|
): string => {
|
|
259
279
|
const baseUrl = this.$config.url.endsWith('/')
|
|
260
280
|
? this.$config.url.slice(0, -1)
|
|
@@ -265,15 +285,24 @@ export class TestApi {
|
|
|
265
285
|
path,
|
|
266
286
|
);
|
|
267
287
|
const queryString = Object.entries(queryParameters)
|
|
268
|
-
.
|
|
288
|
+
.flatMap(([key, value]) => {
|
|
269
289
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
270
|
-
return value
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
290
|
+
return value.map(
|
|
291
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
if (
|
|
295
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
296
|
+
value !== null &&
|
|
297
|
+
typeof value === 'object'
|
|
298
|
+
) {
|
|
299
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
275
300
|
}
|
|
276
|
-
|
|
301
|
+
const delimiter =
|
|
302
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
303
|
+
return [
|
|
304
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
305
|
+
];
|
|
277
306
|
})
|
|
278
307
|
.join('&');
|
|
279
308
|
return (
|
|
@@ -283,13 +312,22 @@ export class TestApi {
|
|
|
283
312
|
|
|
284
313
|
private $headers = (
|
|
285
314
|
headerParameters: { [key: string]: any },
|
|
286
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
315
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
287
316
|
): [string, string][] => {
|
|
288
317
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
289
318
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
290
319
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
291
320
|
}
|
|
292
|
-
|
|
321
|
+
const delimiter =
|
|
322
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
323
|
+
return [
|
|
324
|
+
[
|
|
325
|
+
key,
|
|
326
|
+
Array.isArray(value)
|
|
327
|
+
? value.map(String).join(delimiter)
|
|
328
|
+
: String(value),
|
|
329
|
+
],
|
|
330
|
+
];
|
|
293
331
|
});
|
|
294
332
|
};
|
|
295
333
|
|
|
@@ -301,16 +339,21 @@ export class TestApi {
|
|
|
301
339
|
const queryParameters: { [key: string]: any } =
|
|
302
340
|
$IO.EchoRequestQueryParameters.toJson(input);
|
|
303
341
|
const headerParameters: { [key: string]: any } = {};
|
|
304
|
-
const
|
|
342
|
+
const queryCollectionFormats = {
|
|
305
343
|
message: 'multi',
|
|
306
344
|
} as const;
|
|
307
345
|
|
|
308
346
|
const body = undefined;
|
|
309
347
|
|
|
310
348
|
const response = await this.$fetch(
|
|
311
|
-
this.$url(
|
|
349
|
+
this.$url(
|
|
350
|
+
'/echo',
|
|
351
|
+
pathParameters,
|
|
352
|
+
queryParameters,
|
|
353
|
+
queryCollectionFormats,
|
|
354
|
+
),
|
|
312
355
|
{
|
|
313
|
-
headers: this.$headers(headerParameters
|
|
356
|
+
headers: this.$headers(headerParameters),
|
|
314
357
|
method: 'GET',
|
|
315
358
|
body,
|
|
316
359
|
},
|
|
@@ -375,7 +418,7 @@ exports[`openApiTsClientGenerator - FastAPI > should handle FastAPI validation e
|
|
|
375
418
|
* Utility for serialisation and deserialisation of API types.
|
|
376
419
|
*/
|
|
377
420
|
export class $IO {
|
|
378
|
-
|
|
421
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
379
422
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
380
423
|
|
|
381
424
|
public static LocationItem = {
|
|
@@ -466,7 +509,7 @@ export class $IO {
|
|
|
466
509
|
...(model.loc === undefined
|
|
467
510
|
? {}
|
|
468
511
|
: {
|
|
469
|
-
loc: model.loc.map(
|
|
512
|
+
loc: model.loc.map($IO.LocationItem.toJson),
|
|
470
513
|
}),
|
|
471
514
|
...(model.msg === undefined
|
|
472
515
|
? {}
|
|
@@ -485,7 +528,7 @@ export class $IO {
|
|
|
485
528
|
return json;
|
|
486
529
|
}
|
|
487
530
|
return {
|
|
488
|
-
loc: (json['loc'] as Array<any>).map(
|
|
531
|
+
loc: (json['loc'] as Array<any>).map($IO.LocationItem.fromJson),
|
|
489
532
|
msg: json['msg'],
|
|
490
533
|
type: json['type'],
|
|
491
534
|
};
|
|
@@ -531,11 +574,31 @@ export class TestApi {
|
|
|
531
574
|
this.testValidation = this.testValidation.bind(this);
|
|
532
575
|
}
|
|
533
576
|
|
|
577
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
578
|
+
csv: ',',
|
|
579
|
+
ssv: ' ',
|
|
580
|
+
pipes: '|',
|
|
581
|
+
};
|
|
582
|
+
|
|
583
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
584
|
+
if (value === undefined || value === null) {
|
|
585
|
+
return [];
|
|
586
|
+
}
|
|
587
|
+
if (typeof value !== 'object') {
|
|
588
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
589
|
+
}
|
|
590
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
591
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
592
|
+
);
|
|
593
|
+
};
|
|
594
|
+
|
|
534
595
|
private $url = (
|
|
535
596
|
path: string,
|
|
536
597
|
pathParameters: { [key: string]: any },
|
|
537
598
|
queryParameters: { [key: string]: any },
|
|
538
|
-
collectionFormats?: {
|
|
599
|
+
collectionFormats?: {
|
|
600
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
601
|
+
},
|
|
539
602
|
): string => {
|
|
540
603
|
const baseUrl = this.$config.url.endsWith('/')
|
|
541
604
|
? this.$config.url.slice(0, -1)
|
|
@@ -546,15 +609,24 @@ export class TestApi {
|
|
|
546
609
|
path,
|
|
547
610
|
);
|
|
548
611
|
const queryString = Object.entries(queryParameters)
|
|
549
|
-
.
|
|
612
|
+
.flatMap(([key, value]) => {
|
|
550
613
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
551
|
-
return value
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
614
|
+
return value.map(
|
|
615
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
616
|
+
);
|
|
617
|
+
}
|
|
618
|
+
if (
|
|
619
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
620
|
+
value !== null &&
|
|
621
|
+
typeof value === 'object'
|
|
622
|
+
) {
|
|
623
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
556
624
|
}
|
|
557
|
-
|
|
625
|
+
const delimiter =
|
|
626
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
627
|
+
return [
|
|
628
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
629
|
+
];
|
|
558
630
|
})
|
|
559
631
|
.join('&');
|
|
560
632
|
return (
|
|
@@ -564,13 +636,22 @@ export class TestApi {
|
|
|
564
636
|
|
|
565
637
|
private $headers = (
|
|
566
638
|
headerParameters: { [key: string]: any },
|
|
567
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
639
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
568
640
|
): [string, string][] => {
|
|
569
641
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
570
642
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
571
643
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
572
644
|
}
|
|
573
|
-
|
|
645
|
+
const delimiter =
|
|
646
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
647
|
+
return [
|
|
648
|
+
[
|
|
649
|
+
key,
|
|
650
|
+
Array.isArray(value)
|
|
651
|
+
? value.map(String).join(delimiter)
|
|
652
|
+
: String(value),
|
|
653
|
+
],
|
|
654
|
+
];
|
|
574
655
|
});
|
|
575
656
|
};
|
|
576
657
|
|
|
@@ -801,7 +882,7 @@ exports[`openApiTsClientGenerator - FastAPI > should handle schemas with hyphens
|
|
|
801
882
|
* Utility for serialisation and deserialisation of API types.
|
|
802
883
|
*/
|
|
803
884
|
export class $IO {
|
|
804
|
-
|
|
885
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
805
886
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
806
887
|
|
|
807
888
|
public static ContentBlockInput = {
|
|
@@ -1674,7 +1755,7 @@ export class $IO {
|
|
|
1674
1755
|
...(model.loc === undefined
|
|
1675
1756
|
? {}
|
|
1676
1757
|
: {
|
|
1677
|
-
loc: model.loc.map(
|
|
1758
|
+
loc: model.loc.map($IO.LocationItem.toJson),
|
|
1678
1759
|
}),
|
|
1679
1760
|
...(model.msg === undefined
|
|
1680
1761
|
? {}
|
|
@@ -1693,7 +1774,7 @@ export class $IO {
|
|
|
1693
1774
|
return json;
|
|
1694
1775
|
}
|
|
1695
1776
|
return {
|
|
1696
|
-
loc: (json['loc'] as Array<any>).map(
|
|
1777
|
+
loc: (json['loc'] as Array<any>).map($IO.LocationItem.fromJson),
|
|
1697
1778
|
msg: json['msg'],
|
|
1698
1779
|
type: json['type'],
|
|
1699
1780
|
};
|
|
@@ -1741,11 +1822,31 @@ export class TestApi {
|
|
|
1741
1822
|
this.ping = this.ping.bind(this);
|
|
1742
1823
|
}
|
|
1743
1824
|
|
|
1825
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
1826
|
+
csv: ',',
|
|
1827
|
+
ssv: ' ',
|
|
1828
|
+
pipes: '|',
|
|
1829
|
+
};
|
|
1830
|
+
|
|
1831
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
1832
|
+
if (value === undefined || value === null) {
|
|
1833
|
+
return [];
|
|
1834
|
+
}
|
|
1835
|
+
if (typeof value !== 'object') {
|
|
1836
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
1837
|
+
}
|
|
1838
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
1839
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
1840
|
+
);
|
|
1841
|
+
};
|
|
1842
|
+
|
|
1744
1843
|
private $url = (
|
|
1745
1844
|
path: string,
|
|
1746
1845
|
pathParameters: { [key: string]: any },
|
|
1747
1846
|
queryParameters: { [key: string]: any },
|
|
1748
|
-
collectionFormats?: {
|
|
1847
|
+
collectionFormats?: {
|
|
1848
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
1849
|
+
},
|
|
1749
1850
|
): string => {
|
|
1750
1851
|
const baseUrl = this.$config.url.endsWith('/')
|
|
1751
1852
|
? this.$config.url.slice(0, -1)
|
|
@@ -1756,15 +1857,24 @@ export class TestApi {
|
|
|
1756
1857
|
path,
|
|
1757
1858
|
);
|
|
1758
1859
|
const queryString = Object.entries(queryParameters)
|
|
1759
|
-
.
|
|
1860
|
+
.flatMap(([key, value]) => {
|
|
1760
1861
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1761
|
-
return value
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1862
|
+
return value.map(
|
|
1863
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
1864
|
+
);
|
|
1865
|
+
}
|
|
1866
|
+
if (
|
|
1867
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
1868
|
+
value !== null &&
|
|
1869
|
+
typeof value === 'object'
|
|
1870
|
+
) {
|
|
1871
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
1766
1872
|
}
|
|
1767
|
-
|
|
1873
|
+
const delimiter =
|
|
1874
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
1875
|
+
return [
|
|
1876
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
1877
|
+
];
|
|
1768
1878
|
})
|
|
1769
1879
|
.join('&');
|
|
1770
1880
|
return (
|
|
@@ -1774,13 +1884,22 @@ export class TestApi {
|
|
|
1774
1884
|
|
|
1775
1885
|
private $headers = (
|
|
1776
1886
|
headerParameters: { [key: string]: any },
|
|
1777
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
1887
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
1778
1888
|
): [string, string][] => {
|
|
1779
1889
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
1780
1890
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
1781
1891
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
1782
1892
|
}
|
|
1783
|
-
|
|
1893
|
+
const delimiter =
|
|
1894
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
1895
|
+
return [
|
|
1896
|
+
[
|
|
1897
|
+
key,
|
|
1898
|
+
Array.isArray(value)
|
|
1899
|
+
? value.map(String).join(delimiter)
|
|
1900
|
+
: String(value),
|
|
1901
|
+
],
|
|
1902
|
+
];
|
|
1784
1903
|
});
|
|
1785
1904
|
};
|
|
1786
1905
|
|
|
@@ -1846,7 +1965,7 @@ export class TestApi {
|
|
|
1846
1965
|
const queryParameters: { [key: string]: any } =
|
|
1847
1966
|
$IO.ListMessagesRequestQueryParameters.toJson(input);
|
|
1848
1967
|
const headerParameters: { [key: string]: any } = {};
|
|
1849
|
-
const
|
|
1968
|
+
const queryCollectionFormats = {
|
|
1850
1969
|
session_id: 'multi',
|
|
1851
1970
|
} as const;
|
|
1852
1971
|
|
|
@@ -1857,10 +1976,10 @@ export class TestApi {
|
|
|
1857
1976
|
'/messages',
|
|
1858
1977
|
pathParameters,
|
|
1859
1978
|
queryParameters,
|
|
1860
|
-
|
|
1979
|
+
queryCollectionFormats,
|
|
1861
1980
|
),
|
|
1862
1981
|
{
|
|
1863
|
-
headers: this.$headers(headerParameters
|
|
1982
|
+
headers: this.$headers(headerParameters),
|
|
1864
1983
|
method: 'GET',
|
|
1865
1984
|
body,
|
|
1866
1985
|
},
|
|
@@ -1935,7 +2054,7 @@ exports[`openApiTsClientGenerator - FastAPI > should hoist inline composite para
|
|
|
1935
2054
|
* Utility for serialisation and deserialisation of API types.
|
|
1936
2055
|
*/
|
|
1937
2056
|
export class $IO {
|
|
1938
|
-
|
|
2057
|
+
public static $mapValues = (data: any, fn: (item: any) => any) =>
|
|
1939
2058
|
Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
|
|
1940
2059
|
|
|
1941
2060
|
public static GetPetRequestCookieParameters = {
|
|
@@ -2152,11 +2271,31 @@ export class TestApi {
|
|
|
2152
2271
|
this.getPet = this.getPet.bind(this);
|
|
2153
2272
|
}
|
|
2154
2273
|
|
|
2274
|
+
private $collectionDelimiters: { [format: string]: string } = {
|
|
2275
|
+
csv: ',',
|
|
2276
|
+
ssv: ' ',
|
|
2277
|
+
pipes: '|',
|
|
2278
|
+
};
|
|
2279
|
+
|
|
2280
|
+
private $deepObject = (key: string, value: any): string[] => {
|
|
2281
|
+
if (value === undefined || value === null) {
|
|
2282
|
+
return [];
|
|
2283
|
+
}
|
|
2284
|
+
if (typeof value !== 'object') {
|
|
2285
|
+
return [\`\${key}=\${encodeURIComponent(String(value))}\`];
|
|
2286
|
+
}
|
|
2287
|
+
return Object.entries(value).flatMap(([prop, v]) =>
|
|
2288
|
+
this.$deepObject(\`\${key}[\${encodeURIComponent(prop)}]\`, v),
|
|
2289
|
+
);
|
|
2290
|
+
};
|
|
2291
|
+
|
|
2155
2292
|
private $url = (
|
|
2156
2293
|
path: string,
|
|
2157
2294
|
pathParameters: { [key: string]: any },
|
|
2158
2295
|
queryParameters: { [key: string]: any },
|
|
2159
|
-
collectionFormats?: {
|
|
2296
|
+
collectionFormats?: {
|
|
2297
|
+
[key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' | 'deepObject';
|
|
2298
|
+
},
|
|
2160
2299
|
): string => {
|
|
2161
2300
|
const baseUrl = this.$config.url.endsWith('/')
|
|
2162
2301
|
? this.$config.url.slice(0, -1)
|
|
@@ -2167,15 +2306,24 @@ export class TestApi {
|
|
|
2167
2306
|
path,
|
|
2168
2307
|
);
|
|
2169
2308
|
const queryString = Object.entries(queryParameters)
|
|
2170
|
-
.
|
|
2309
|
+
.flatMap(([key, value]) => {
|
|
2171
2310
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
2172
|
-
return value
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2311
|
+
return value.map(
|
|
2312
|
+
(v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
if (
|
|
2316
|
+
collectionFormats?.[key] === 'deepObject' &&
|
|
2317
|
+
value !== null &&
|
|
2318
|
+
typeof value === 'object'
|
|
2319
|
+
) {
|
|
2320
|
+
return this.$deepObject(encodeURIComponent(key), value);
|
|
2177
2321
|
}
|
|
2178
|
-
|
|
2322
|
+
const delimiter =
|
|
2323
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
2324
|
+
return [
|
|
2325
|
+
\`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(delimiter) : String(value))}\`,
|
|
2326
|
+
];
|
|
2179
2327
|
})
|
|
2180
2328
|
.join('&');
|
|
2181
2329
|
return (
|
|
@@ -2185,13 +2333,22 @@ export class TestApi {
|
|
|
2185
2333
|
|
|
2186
2334
|
private $headers = (
|
|
2187
2335
|
headerParameters: { [key: string]: any },
|
|
2188
|
-
collectionFormats?: { [key: string]: 'multi' | 'csv' },
|
|
2336
|
+
collectionFormats?: { [key: string]: 'multi' | 'csv' | 'ssv' | 'pipes' },
|
|
2189
2337
|
): [string, string][] => {
|
|
2190
2338
|
return Object.entries(headerParameters).flatMap(([key, value]) => {
|
|
2191
2339
|
if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
|
|
2192
2340
|
return value.map((v) => [key, String(v)]) as [string, string][];
|
|
2193
2341
|
}
|
|
2194
|
-
|
|
2342
|
+
const delimiter =
|
|
2343
|
+
this.$collectionDelimiters[collectionFormats?.[key] ?? 'csv'] ?? ',';
|
|
2344
|
+
return [
|
|
2345
|
+
[
|
|
2346
|
+
key,
|
|
2347
|
+
Array.isArray(value)
|
|
2348
|
+
? value.map(String).join(delimiter)
|
|
2349
|
+
: String(value),
|
|
2350
|
+
],
|
|
2351
|
+
];
|
|
2195
2352
|
});
|
|
2196
2353
|
};
|
|
2197
2354
|
|
|
@@ -2215,10 +2372,12 @@ export class TestApi {
|
|
|
2215
2372
|
if (cookiePairs.length > 0) {
|
|
2216
2373
|
headerParameters['Cookie'] = cookiePairs.join('; ');
|
|
2217
2374
|
}
|
|
2218
|
-
const
|
|
2219
|
-
'X-Client': 'csv',
|
|
2375
|
+
const queryCollectionFormats = {
|
|
2220
2376
|
tag: 'multi',
|
|
2221
2377
|
} as const;
|
|
2378
|
+
const headerCollectionFormats = {
|
|
2379
|
+
'X-Client': 'csv',
|
|
2380
|
+
} as const;
|
|
2222
2381
|
|
|
2223
2382
|
const body = undefined;
|
|
2224
2383
|
|
|
@@ -2227,10 +2386,10 @@ export class TestApi {
|
|
|
2227
2386
|
'/pets/{petId}',
|
|
2228
2387
|
pathParameters,
|
|
2229
2388
|
queryParameters,
|
|
2230
|
-
|
|
2389
|
+
queryCollectionFormats,
|
|
2231
2390
|
),
|
|
2232
2391
|
{
|
|
2233
|
-
headers: this.$headers(headerParameters,
|
|
2392
|
+
headers: this.$headers(headerParameters, headerCollectionFormats),
|
|
2234
2393
|
method: 'GET',
|
|
2235
2394
|
body,
|
|
2236
2395
|
},
|