@aws/nx-plugin 0.103.0 → 0.104.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.
Files changed (22) hide show
  1. package/package.json +1 -1
  2. package/src/open-api/ts-client/__snapshots__/generator.additional-properties.spec.ts.snap +202 -0
  3. package/src/open-api/ts-client/__snapshots__/generator.content-type.spec.ts.snap +475 -0
  4. package/src/open-api/ts-client/__snapshots__/generator.fast-api.spec.ts.snap +353 -0
  5. package/src/open-api/ts-client/files/client.gen.ts.template +22 -1
  6. package/src/open-api/ts-client/files/types.gen.ts.template +5 -1
  7. package/src/open-api/utils/codegen-data.js +7 -2
  8. package/src/open-api/utils/codegen-data.js.map +1 -1
  9. package/src/open-api/utils/normalise.js +14 -0
  10. package/src/open-api/utils/normalise.js.map +1 -1
  11. package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +8 -8
  12. package/src/py/lambda-function/__snapshots__/generator.spec.ts.snap +3 -3
  13. package/src/py/mcp-server/files/deploy/Dockerfile.template +1 -1
  14. package/src/py/project/generator.js +4 -4
  15. package/src/py/strands-agent/__snapshots__/generator.spec.ts.snap +1 -1
  16. package/src/py/strands-agent/files/deploy/Dockerfile.template +1 -1
  17. package/src/utils/agent-connection/files/py-core-auth/auth/sigv4.py.template +1 -1
  18. package/src/utils/api-constructs/files/cdk/app/apis/http/__apiNameKebabCase__.ts.template +1 -1
  19. package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +1 -1
  20. package/src/utils/api-constructs/files/terraform/app/apis/http/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -1
  21. package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +1 -1
  22. package/src/utils/function-constructs/function-constructs.js +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws/nx-plugin",
3
- "version": "0.103.0",
3
+ "version": "0.104.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/awslabs/nx-plugin-for-aws.git",
@@ -2234,3 +2234,205 @@ export class TestApi {
2234
2234
  }
2235
2235
  "
2236
2236
  `;
2237
+
2238
+ exports[`openApiTsClientGenerator - complex types > should render \`unknown\` value type for \`type: object\` with no additionalProperties > client.gen.ts 1`] = `
2239
+ "import type {
2240
+ GetAdditionalPropsTrue200Response,
2241
+ GetBareObject200Response,
2242
+ } from './types.gen.js';
2243
+
2244
+ /**
2245
+ * Utility for serialisation and deserialisation of API types.
2246
+ */
2247
+ export class $IO {
2248
+ protected static $mapValues = (data: any, fn: (item: any) => any) =>
2249
+ Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
2250
+
2251
+ public static GetAdditionalPropsTrue200Response = {
2252
+ toJson: (model: GetAdditionalPropsTrue200Response): any => {
2253
+ if (model === undefined || model === null) {
2254
+ return model;
2255
+ }
2256
+ return {
2257
+ ...$IO.$mapValues(model, (item0) => item0),
2258
+ };
2259
+ },
2260
+ fromJson: (json: any): GetAdditionalPropsTrue200Response => {
2261
+ if (json === undefined || json === null) {
2262
+ return json;
2263
+ }
2264
+ return {
2265
+ ...$IO.$mapValues(json, (item0) => item0),
2266
+ };
2267
+ },
2268
+ };
2269
+
2270
+ public static GetBareObject200Response = {
2271
+ toJson: (model: GetBareObject200Response): any => {
2272
+ if (model === undefined || model === null) {
2273
+ return model;
2274
+ }
2275
+ return {
2276
+ ...$IO.$mapValues(model, (item0) => item0),
2277
+ };
2278
+ },
2279
+ fromJson: (json: any): GetBareObject200Response => {
2280
+ if (json === undefined || json === null) {
2281
+ return json;
2282
+ }
2283
+ return {
2284
+ ...$IO.$mapValues(json, (item0) => item0),
2285
+ };
2286
+ },
2287
+ };
2288
+ }
2289
+
2290
+ /**
2291
+ * Client configuration for TestApi
2292
+ */
2293
+ export interface TestApiConfig {
2294
+ /**
2295
+ * Base URL for the API
2296
+ */
2297
+ url: string;
2298
+ /**
2299
+ * Custom instance of fetch. By default the global 'fetch' is used.
2300
+ * You can override this to add custom middleware for use cases such as adding authentication headers.
2301
+ */
2302
+ fetch?: typeof fetch;
2303
+ /**
2304
+ * Additional configuration
2305
+ */
2306
+ options?: {
2307
+ /**
2308
+ * By default, the client will add a Content-Type header, set to the media type defined for
2309
+ * the request in the OpenAPI specification.
2310
+ * Set this to false to omit this header.
2311
+ */
2312
+ omitContentTypeHeader?: boolean;
2313
+ };
2314
+ }
2315
+
2316
+ /**
2317
+ * API Client for TestApi
2318
+ */
2319
+ export class TestApi {
2320
+ private $config: TestApiConfig;
2321
+
2322
+ constructor(config: TestApiConfig) {
2323
+ this.$config = config;
2324
+
2325
+ this.getAdditionalPropsTrue = this.getAdditionalPropsTrue.bind(this);
2326
+ this.getBareObject = this.getBareObject.bind(this);
2327
+ }
2328
+
2329
+ private $url = (
2330
+ path: string,
2331
+ pathParameters: { [key: string]: any },
2332
+ queryParameters: { [key: string]: any },
2333
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
2334
+ ): string => {
2335
+ const baseUrl = this.$config.url.endsWith('/')
2336
+ ? this.$config.url.slice(0, -1)
2337
+ : this.$config.url;
2338
+ const pathWithParameters = Object.entries(pathParameters).reduce(
2339
+ (withParams, [key, value]) =>
2340
+ withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
2341
+ path,
2342
+ );
2343
+ const queryString = Object.entries(queryParameters)
2344
+ .map(([key, value]) => {
2345
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
2346
+ return value
2347
+ .map(
2348
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
2349
+ )
2350
+ .join('&');
2351
+ }
2352
+ return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
2353
+ })
2354
+ .join('&');
2355
+ return (
2356
+ baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
2357
+ );
2358
+ };
2359
+
2360
+ private $headers = (
2361
+ headerParameters: { [key: string]: any },
2362
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
2363
+ ): [string, string][] => {
2364
+ return Object.entries(headerParameters).flatMap(([key, value]) => {
2365
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
2366
+ return value.map((v) => [key, String(v)]) as [string, string][];
2367
+ }
2368
+ return [[key, String(value)]];
2369
+ });
2370
+ };
2371
+
2372
+ private $fetch: typeof fetch = (...args) =>
2373
+ (this.$config.fetch ?? fetch)(...args);
2374
+
2375
+ public async getAdditionalPropsTrue(): Promise<GetAdditionalPropsTrue200Response> {
2376
+ const pathParameters: { [key: string]: any } = {};
2377
+ const queryParameters: { [key: string]: any } = {};
2378
+ const headerParameters: { [key: string]: any } = {};
2379
+
2380
+ const body = undefined;
2381
+
2382
+ const response = await this.$fetch(
2383
+ this.$url('/ap-true', pathParameters, queryParameters),
2384
+ {
2385
+ headers: this.$headers(headerParameters),
2386
+ method: 'GET',
2387
+ body,
2388
+ },
2389
+ );
2390
+
2391
+ if (response.status === 200) {
2392
+ return $IO.GetAdditionalPropsTrue200Response.fromJson(
2393
+ await response.json(),
2394
+ );
2395
+ }
2396
+ throw new Error(
2397
+ \`Unknown response status \${response.status} returned by API\`,
2398
+ );
2399
+ }
2400
+
2401
+ public async getBareObject(): Promise<GetBareObject200Response> {
2402
+ const pathParameters: { [key: string]: any } = {};
2403
+ const queryParameters: { [key: string]: any } = {};
2404
+ const headerParameters: { [key: string]: any } = {};
2405
+
2406
+ const body = undefined;
2407
+
2408
+ const response = await this.$fetch(
2409
+ this.$url('/bare-object', pathParameters, queryParameters),
2410
+ {
2411
+ headers: this.$headers(headerParameters),
2412
+ method: 'GET',
2413
+ body,
2414
+ },
2415
+ );
2416
+
2417
+ if (response.status === 200) {
2418
+ return $IO.GetBareObject200Response.fromJson(await response.json());
2419
+ }
2420
+ throw new Error(
2421
+ \`Unknown response status \${response.status} returned by API\`,
2422
+ );
2423
+ }
2424
+ }
2425
+ "
2426
+ `;
2427
+
2428
+ exports[`openApiTsClientGenerator - complex types > should render \`unknown\` value type for \`type: object\` with no additionalProperties > types.gen.ts 1`] = `
2429
+ "export type GetAdditionalPropsTrue200Response = {
2430
+ [key: string]: unknown;
2431
+ };
2432
+ export type GetBareObject200Response = {
2433
+ [key: string]: unknown;
2434
+ };
2435
+ export type GetAdditionalPropsTrueError = never;
2436
+ export type GetBareObjectError = never;
2437
+ "
2438
+ `;
@@ -0,0 +1,475 @@
1
+ // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
+
3
+ exports[`openApiTsClientGenerator - content type header > should not force Content-Type for multipart/form-data bodies > client.gen.ts 1`] = `
4
+ "import type { PostUploadRequest } from './types.gen.js';
5
+
6
+ /**
7
+ * Utility for serialisation and deserialisation of API types.
8
+ */
9
+ export class $IO {
10
+ protected static $mapValues = (data: any, fn: (item: any) => any) =>
11
+ Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
12
+ }
13
+
14
+ /**
15
+ * Client configuration for TestApi
16
+ */
17
+ export interface TestApiConfig {
18
+ /**
19
+ * Base URL for the API
20
+ */
21
+ url: string;
22
+ /**
23
+ * Custom instance of fetch. By default the global 'fetch' is used.
24
+ * You can override this to add custom middleware for use cases such as adding authentication headers.
25
+ */
26
+ fetch?: typeof fetch;
27
+ /**
28
+ * Additional configuration
29
+ */
30
+ options?: {
31
+ /**
32
+ * By default, the client will add a Content-Type header, set to the media type defined for
33
+ * the request in the OpenAPI specification.
34
+ * Set this to false to omit this header.
35
+ */
36
+ omitContentTypeHeader?: boolean;
37
+ };
38
+ }
39
+
40
+ /**
41
+ * API Client for TestApi
42
+ */
43
+ export class TestApi {
44
+ private $config: TestApiConfig;
45
+
46
+ constructor(config: TestApiConfig) {
47
+ this.$config = config;
48
+
49
+ this.postUpload = this.postUpload.bind(this);
50
+ }
51
+
52
+ private $url = (
53
+ path: string,
54
+ pathParameters: { [key: string]: any },
55
+ queryParameters: { [key: string]: any },
56
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
57
+ ): string => {
58
+ const baseUrl = this.$config.url.endsWith('/')
59
+ ? this.$config.url.slice(0, -1)
60
+ : this.$config.url;
61
+ const pathWithParameters = Object.entries(pathParameters).reduce(
62
+ (withParams, [key, value]) =>
63
+ withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
64
+ path,
65
+ );
66
+ const queryString = Object.entries(queryParameters)
67
+ .map(([key, value]) => {
68
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
69
+ return value
70
+ .map(
71
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
72
+ )
73
+ .join('&');
74
+ }
75
+ return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
76
+ })
77
+ .join('&');
78
+ return (
79
+ baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
80
+ );
81
+ };
82
+
83
+ private $headers = (
84
+ headerParameters: { [key: string]: any },
85
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
86
+ ): [string, string][] => {
87
+ return Object.entries(headerParameters).flatMap(([key, value]) => {
88
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
89
+ return value.map((v) => [key, String(v)]) as [string, string][];
90
+ }
91
+ return [[key, String(value)]];
92
+ });
93
+ };
94
+
95
+ private $fetch: typeof fetch = (...args) =>
96
+ (this.$config.fetch ?? fetch)(...args);
97
+
98
+ public async postUpload(input: PostUploadRequest): Promise<void> {
99
+ const pathParameters: { [key: string]: any } = {};
100
+ const queryParameters: { [key: string]: any } = {};
101
+ const headerParameters: { [key: string]: any } = {};
102
+ const body = input as any;
103
+
104
+ const response = await this.$fetch(
105
+ this.$url('/upload', pathParameters, queryParameters),
106
+ {
107
+ headers: this.$headers(headerParameters),
108
+ method: 'POST',
109
+ body,
110
+ },
111
+ );
112
+
113
+ if (response.status === 204) {
114
+ return undefined;
115
+ }
116
+ throw new Error(
117
+ \`Unknown response status \${response.status} returned by API\`,
118
+ );
119
+ }
120
+ }
121
+ "
122
+ `;
123
+
124
+ exports[`openApiTsClientGenerator - content type header > should not force Content-Type for multipart/form-data bodies > types.gen.ts 1`] = `
125
+ "export type PostUploadRequest = unknown;
126
+ export type PostUploadError = never;
127
+ "
128
+ `;
129
+
130
+ exports[`openApiTsClientGenerator - content type header > should pick a single wire media type when the spec lists multiple > client.gen.ts 1`] = `
131
+ "import type { PostMultiRequestContent, PostMultiRequest } from './types.gen.js';
132
+
133
+ /**
134
+ * Utility for serialisation and deserialisation of API types.
135
+ */
136
+ export class $IO {
137
+ protected static $mapValues = (data: any, fn: (item: any) => any) =>
138
+ Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
139
+
140
+ public static PostMultiRequestContent = {
141
+ toJson: (model: PostMultiRequestContent): any => {
142
+ if (model === undefined || model === null) {
143
+ return model;
144
+ }
145
+ return {
146
+ ...(model.m === undefined
147
+ ? {}
148
+ : {
149
+ m: model.m,
150
+ }),
151
+ };
152
+ },
153
+ fromJson: (json: any): PostMultiRequestContent => {
154
+ if (json === undefined || json === null) {
155
+ return json;
156
+ }
157
+ return {
158
+ ...(json['m'] === undefined
159
+ ? {}
160
+ : {
161
+ m: json['m'],
162
+ }),
163
+ };
164
+ },
165
+ };
166
+ }
167
+
168
+ /**
169
+ * Client configuration for TestApi
170
+ */
171
+ export interface TestApiConfig {
172
+ /**
173
+ * Base URL for the API
174
+ */
175
+ url: string;
176
+ /**
177
+ * Custom instance of fetch. By default the global 'fetch' is used.
178
+ * You can override this to add custom middleware for use cases such as adding authentication headers.
179
+ */
180
+ fetch?: typeof fetch;
181
+ /**
182
+ * Additional configuration
183
+ */
184
+ options?: {
185
+ /**
186
+ * By default, the client will add a Content-Type header, set to the media type defined for
187
+ * the request in the OpenAPI specification.
188
+ * Set this to false to omit this header.
189
+ */
190
+ omitContentTypeHeader?: boolean;
191
+ };
192
+ }
193
+
194
+ /**
195
+ * API Client for TestApi
196
+ */
197
+ export class TestApi {
198
+ private $config: TestApiConfig;
199
+
200
+ constructor(config: TestApiConfig) {
201
+ this.$config = config;
202
+
203
+ this.postMulti = this.postMulti.bind(this);
204
+ }
205
+
206
+ private $url = (
207
+ path: string,
208
+ pathParameters: { [key: string]: any },
209
+ queryParameters: { [key: string]: any },
210
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
211
+ ): string => {
212
+ const baseUrl = this.$config.url.endsWith('/')
213
+ ? this.$config.url.slice(0, -1)
214
+ : this.$config.url;
215
+ const pathWithParameters = Object.entries(pathParameters).reduce(
216
+ (withParams, [key, value]) =>
217
+ withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
218
+ path,
219
+ );
220
+ const queryString = Object.entries(queryParameters)
221
+ .map(([key, value]) => {
222
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
223
+ return value
224
+ .map(
225
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
226
+ )
227
+ .join('&');
228
+ }
229
+ return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
230
+ })
231
+ .join('&');
232
+ return (
233
+ baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
234
+ );
235
+ };
236
+
237
+ private $headers = (
238
+ headerParameters: { [key: string]: any },
239
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
240
+ ): [string, string][] => {
241
+ return Object.entries(headerParameters).flatMap(([key, value]) => {
242
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
243
+ return value.map((v) => [key, String(v)]) as [string, string][];
244
+ }
245
+ return [[key, String(value)]];
246
+ });
247
+ };
248
+
249
+ private $fetch: typeof fetch = (...args) =>
250
+ (this.$config.fetch ?? fetch)(...args);
251
+
252
+ public async postMulti(input: PostMultiRequest): Promise<void> {
253
+ const pathParameters: { [key: string]: any } = {};
254
+ const queryParameters: { [key: string]: any } = {};
255
+ const headerParameters: { [key: string]: any } = {};
256
+ if (!this.$config.options?.omitContentTypeHeader) {
257
+ headerParameters['Content-Type'] = 'application/json';
258
+ }
259
+ const body =
260
+ typeof input === 'object'
261
+ ? JSON.stringify($IO.PostMultiRequestContent.toJson(input))
262
+ : String($IO.PostMultiRequestContent.toJson(input));
263
+
264
+ const response = await this.$fetch(
265
+ this.$url('/multi', pathParameters, queryParameters),
266
+ {
267
+ headers: this.$headers(headerParameters),
268
+ method: 'POST',
269
+ body,
270
+ },
271
+ );
272
+
273
+ if (response.status === 204) {
274
+ return undefined;
275
+ }
276
+ throw new Error(
277
+ \`Unknown response status \${response.status} returned by API\`,
278
+ );
279
+ }
280
+ }
281
+ "
282
+ `;
283
+
284
+ exports[`openApiTsClientGenerator - content type header > should pick a single wire media type when the spec lists multiple > types.gen.ts 1`] = `
285
+ "export type PostMultiRequestContent = {
286
+ m?: string;
287
+ };
288
+
289
+ export type PostMultiRequest = PostMultiRequestContent;
290
+ export type PostMultiError = never;
291
+ "
292
+ `;
293
+
294
+ exports[`openApiTsClientGenerator - content type header > should serialise cookie parameters into a Cookie request header > client.gen.ts 1`] = `
295
+ "import type {
296
+ GetSecretRequestCookieParameters,
297
+ GetSecretRequest,
298
+ } from './types.gen.js';
299
+
300
+ /**
301
+ * Utility for serialisation and deserialisation of API types.
302
+ */
303
+ export class $IO {
304
+ protected static $mapValues = (data: any, fn: (item: any) => any) =>
305
+ Object.fromEntries(Object.entries(data).map(([k, v]) => [k, fn(v)]));
306
+
307
+ public static GetSecretRequestCookieParameters = {
308
+ toJson: (model: GetSecretRequestCookieParameters): any => {
309
+ if (model === undefined || model === null) {
310
+ return model;
311
+ }
312
+ return {
313
+ ...(model.session === undefined
314
+ ? {}
315
+ : {
316
+ session: model.session,
317
+ }),
318
+ ...(model.preference === undefined
319
+ ? {}
320
+ : {
321
+ preference: model.preference,
322
+ }),
323
+ };
324
+ },
325
+ fromJson: (json: any): GetSecretRequestCookieParameters => {
326
+ if (json === undefined || json === null) {
327
+ return json;
328
+ }
329
+ return {
330
+ ...(json['session'] === undefined
331
+ ? {}
332
+ : {
333
+ session: json['session'],
334
+ }),
335
+ ...(json['preference'] === undefined
336
+ ? {}
337
+ : {
338
+ preference: json['preference'],
339
+ }),
340
+ };
341
+ },
342
+ };
343
+ }
344
+
345
+ /**
346
+ * Client configuration for TestApi
347
+ */
348
+ export interface TestApiConfig {
349
+ /**
350
+ * Base URL for the API
351
+ */
352
+ url: string;
353
+ /**
354
+ * Custom instance of fetch. By default the global 'fetch' is used.
355
+ * You can override this to add custom middleware for use cases such as adding authentication headers.
356
+ */
357
+ fetch?: typeof fetch;
358
+ /**
359
+ * Additional configuration
360
+ */
361
+ options?: {
362
+ /**
363
+ * By default, the client will add a Content-Type header, set to the media type defined for
364
+ * the request in the OpenAPI specification.
365
+ * Set this to false to omit this header.
366
+ */
367
+ omitContentTypeHeader?: boolean;
368
+ };
369
+ }
370
+
371
+ /**
372
+ * API Client for TestApi
373
+ */
374
+ export class TestApi {
375
+ private $config: TestApiConfig;
376
+
377
+ constructor(config: TestApiConfig) {
378
+ this.$config = config;
379
+
380
+ this.getSecret = this.getSecret.bind(this);
381
+ }
382
+
383
+ private $url = (
384
+ path: string,
385
+ pathParameters: { [key: string]: any },
386
+ queryParameters: { [key: string]: any },
387
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
388
+ ): string => {
389
+ const baseUrl = this.$config.url.endsWith('/')
390
+ ? this.$config.url.slice(0, -1)
391
+ : this.$config.url;
392
+ const pathWithParameters = Object.entries(pathParameters).reduce(
393
+ (withParams, [key, value]) =>
394
+ withParams.replace(\`{\${key}}\`, encodeURIComponent(\`\${value}\`)),
395
+ path,
396
+ );
397
+ const queryString = Object.entries(queryParameters)
398
+ .map(([key, value]) => {
399
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
400
+ return value
401
+ .map(
402
+ (v) => \`\${encodeURIComponent(key)}=\${encodeURIComponent(\`\${v}\`)}\`,
403
+ )
404
+ .join('&');
405
+ }
406
+ return \`\${encodeURIComponent(key)}=\${encodeURIComponent(Array.isArray(value) ? value.map(String).join(',') : String(value))}\`;
407
+ })
408
+ .join('&');
409
+ return (
410
+ baseUrl + pathWithParameters + (queryString ? \`?\${queryString}\` : '')
411
+ );
412
+ };
413
+
414
+ private $headers = (
415
+ headerParameters: { [key: string]: any },
416
+ collectionFormats?: { [key: string]: 'multi' | 'csv' },
417
+ ): [string, string][] => {
418
+ return Object.entries(headerParameters).flatMap(([key, value]) => {
419
+ if (Array.isArray(value) && collectionFormats?.[key] === 'multi') {
420
+ return value.map((v) => [key, String(v)]) as [string, string][];
421
+ }
422
+ return [[key, String(value)]];
423
+ });
424
+ };
425
+
426
+ private $fetch: typeof fetch = (...args) =>
427
+ (this.$config.fetch ?? fetch)(...args);
428
+
429
+ public async getSecret(input: GetSecretRequest): Promise<string> {
430
+ const pathParameters: { [key: string]: any } = {};
431
+ const queryParameters: { [key: string]: any } = {};
432
+ const headerParameters: { [key: string]: any } = {};
433
+ const cookieParameters: { [key: string]: any } =
434
+ $IO.GetSecretRequestCookieParameters.toJson(input);
435
+ const cookiePairs = Object.entries(cookieParameters)
436
+ .filter(([, v]) => v !== undefined && v !== null)
437
+ .map(
438
+ ([k, v]) => \`\${encodeURIComponent(k)}=\${encodeURIComponent(String(v))}\`,
439
+ );
440
+ if (cookiePairs.length > 0) {
441
+ headerParameters['Cookie'] = cookiePairs.join('; ');
442
+ }
443
+
444
+ const body = undefined;
445
+
446
+ const response = await this.$fetch(
447
+ this.$url('/secret', pathParameters, queryParameters),
448
+ {
449
+ headers: this.$headers(headerParameters),
450
+ method: 'GET',
451
+ body,
452
+ },
453
+ );
454
+
455
+ if (response.status === 200) {
456
+ return await response.text();
457
+ }
458
+ throw new Error(
459
+ \`Unknown response status \${response.status} returned by API\`,
460
+ );
461
+ }
462
+ }
463
+ "
464
+ `;
465
+
466
+ exports[`openApiTsClientGenerator - content type header > should serialise cookie parameters into a Cookie request header > types.gen.ts 1`] = `
467
+ "export type GetSecretRequestCookieParameters = {
468
+ session?: string;
469
+ preference?: string;
470
+ };
471
+
472
+ export type GetSecretRequest = GetSecretRequestCookieParameters;
473
+ export type GetSecretError = never;
474
+ "
475
+ `;