openapi-class-transformer 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,506 @@
1
+ {{#withSeparateModelsAndApi}}
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ {{>licenseInfo}}
5
+
6
+ import type { Configuration } from '{{apiRelativeToRoot}}configuration';
7
+ import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
8
+ import globalAxios, { type AxiosResponse } from 'axios';
9
+ import { plainToInstance } from 'class-transformer';
10
+ {{#withNodeImports}}
11
+ // URLSearchParams not necessarily used
12
+ // @ts-ignore
13
+ import { URL, URLSearchParams } from 'url';
14
+ {{#multipartFormData}}
15
+ import FormData from 'form-data'
16
+ {{/multipartFormData}}
17
+ {{/withNodeImports}}
18
+ // Some imports not used depending on template conditions
19
+ // @ts-ignore
20
+ import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '{{apiRelativeToRoot}}common';
21
+ // @ts-ignore
22
+ import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '{{apiRelativeToRoot}}base';
23
+ {{#imports}}
24
+ // @ts-ignore
25
+ import { {{classname}} } from '{{apiRelativeToRoot}}{{tsModelPackage}}';
26
+ {{/imports}}
27
+ {{/withSeparateModelsAndApi}}
28
+ {{^withSeparateModelsAndApi}}
29
+ {{/withSeparateModelsAndApi}}
30
+ {{#operations}}
31
+ /**
32
+ * {{classname}} - axios parameter creator{{#description}}
33
+ * {{&description}}{{/description}}
34
+ * @export
35
+ */
36
+ export const {{classname}}AxiosParamCreator = function (configuration?: Configuration) {
37
+ return {
38
+ {{#operation}}
39
+ /**
40
+ * {{&notes}}
41
+ {{#summary}}
42
+ * @summary {{&summary}}
43
+ {{/summary}}
44
+ {{#allParams}}
45
+ * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
46
+ {{/allParams}}
47
+ * @param {*} [options] Override http request option.{{#isDeprecated}}
48
+ * @deprecated{{/isDeprecated}}
49
+ * @throws {RequiredError}
50
+ */
51
+ {{nickname}}: async ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
52
+ {{#allParams}}
53
+ {{#required}}
54
+ // verify required parameter '{{paramName}}' is not null or undefined
55
+ assertParamExists('{{nickname}}', '{{paramName}}', {{paramName}})
56
+ {{/required}}
57
+ {{/allParams}}
58
+ const localVarPath = `{{{path}}}`{{#pathParams}}
59
+ .replace(`{${"{{baseName}}"}}`, encodeURIComponent(String({{paramName}}))){{/pathParams}};
60
+ // use dummy base URL string because the URL constructor only accepts absolute URLs.
61
+ const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
62
+ let baseOptions;
63
+ if (configuration) {
64
+ baseOptions = configuration.baseOptions;
65
+ }
66
+
67
+ const localVarRequestOptions = { method: '{{httpMethod}}', ...baseOptions, ...options};
68
+ const localVarHeaderParameter = {} as any;
69
+ const localVarQueryParameter = {} as any;{{#vendorExtensions}}{{#hasFormParams}}
70
+ const localVarFormParams = new {{^multipartFormData}}URLSearchParams(){{/multipartFormData}}{{#multipartFormData}}((configuration && configuration.formDataCtor) || FormData)(){{/multipartFormData}};{{/hasFormParams}}{{/vendorExtensions}}
71
+
72
+ {{#authMethods}}
73
+ // authentication {{name}} required
74
+ {{#isApiKey}}
75
+ {{#isKeyInHeader}}
76
+ await setApiKeyToObject(localVarHeaderParameter, "{{keyParamName}}", configuration)
77
+ {{/isKeyInHeader}}
78
+ {{#isKeyInQuery}}
79
+ await setApiKeyToObject(localVarQueryParameter, "{{keyParamName}}", configuration)
80
+ {{/isKeyInQuery}}
81
+ {{/isApiKey}}
82
+ {{#isBasicBasic}}
83
+ // http basic authentication required
84
+ setBasicAuthToObject(localVarRequestOptions, configuration)
85
+ {{/isBasicBasic}}
86
+ {{#isBasicBearer}}
87
+ // http bearer authentication required
88
+ await setBearerAuthToObject(localVarHeaderParameter, configuration)
89
+ {{/isBasicBearer}}
90
+ {{#isOAuth}}
91
+ // oauth required
92
+ await setOAuthToObject(localVarHeaderParameter, "{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}], configuration)
93
+ {{/isOAuth}}
94
+
95
+ {{/authMethods}}
96
+ {{#queryParams}}
97
+ {{#isArray}}
98
+ if ({{paramName}}) {
99
+ {{#isCollectionFormatMulti}}
100
+ {{#uniqueItems}}
101
+ localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}});
102
+ {{/uniqueItems}}
103
+ {{^uniqueItems}}
104
+ localVarQueryParameter['{{baseName}}'] = {{paramName}};
105
+ {{/uniqueItems}}
106
+ {{/isCollectionFormatMulti}}
107
+ {{^isCollectionFormatMulti}}
108
+ {{#uniqueItems}}
109
+ localVarQueryParameter['{{baseName}}'] = Array.from({{paramName}}).join(COLLECTION_FORMATS.{{collectionFormat}});
110
+ {{/uniqueItems}}
111
+ {{^uniqueItems}}
112
+ localVarQueryParameter['{{baseName}}'] = {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}});
113
+ {{/uniqueItems}}
114
+ {{/isCollectionFormatMulti}}
115
+ }
116
+ {{/isArray}}
117
+ {{^isArray}}
118
+ if ({{paramName}} !== undefined) {
119
+ {{#isDateTime}}
120
+ localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ?
121
+ ({{paramName}} as any).toISOString() :
122
+ {{paramName}};
123
+ {{/isDateTime}}
124
+ {{^isDateTime}}
125
+ {{#isDate}}
126
+ localVarQueryParameter['{{baseName}}'] = ({{paramName}} as any instanceof Date) ?
127
+ ({{paramName}} as any).toISOString().substring(0,10) :
128
+ {{paramName}};
129
+ {{/isDate}}
130
+ {{^isDate}}
131
+ {{#isExplode}}
132
+ {{#isPrimitiveType}}
133
+ localVarQueryParameter['{{baseName}}'] = {{paramName}};
134
+ {{/isPrimitiveType}}
135
+ {{^isPrimitiveType}}
136
+ {{^isEnumRef}}
137
+ {{^isEnum}}
138
+ for (const [key, value] of Object.entries({{paramName}})) {
139
+ localVarQueryParameter[key] = value;
140
+ }
141
+ {{/isEnum}}
142
+ {{/isEnumRef}}
143
+ {{#isEnum}}
144
+ localVarQueryParameter['{{baseName}}'] = {{paramName}};
145
+ {{/isEnum}}
146
+ {{#isEnumRef}}
147
+ localVarQueryParameter['{{baseName}}'] = {{paramName}};
148
+ {{/isEnumRef}}
149
+ {{/isPrimitiveType}}
150
+ {{/isExplode}}
151
+ {{^isExplode}}
152
+ localVarQueryParameter['{{baseName}}'] = {{paramName}};
153
+ {{/isExplode}}
154
+ {{/isDate}}
155
+ {{/isDateTime}}
156
+ }
157
+ {{/isArray}}
158
+
159
+ {{/queryParams}}
160
+ {{#vendorExtensions}}
161
+ {{#formParams}}
162
+ {{#isArray}}
163
+ if ({{paramName}}) {
164
+ {{#isCollectionFormatMulti}}
165
+ {{#contentType}}
166
+ localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "{{contentType}}", }));
167
+ {{/contentType}}
168
+ {{^contentType}}
169
+ {{paramName}}.forEach((element) => {
170
+ localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}{{#useSquareBracketsInArrayNames}}[]{{/useSquareBracketsInArrayNames}}', element as any);
171
+ })
172
+ {{/contentType}}
173
+ {{/isCollectionFormatMulti}}
174
+ {{^isCollectionFormatMulti}}
175
+ localVarFormParams.{{#multipartFormData}}append{{/multipartFormData}}{{^multipartFormData}}set{{/multipartFormData}}('{{baseName}}{{#useSquareBracketsInArrayNames}}[]{{/useSquareBracketsInArrayNames}}', {{paramName}}.join(COLLECTION_FORMATS.{{collectionFormat}}));
176
+ {{/isCollectionFormatMulti}}
177
+ }{{/isArray}}
178
+ {{^isArray}}
179
+ if ({{paramName}} !== undefined) { {{^multipartFormData}}
180
+ localVarFormParams.set('{{baseName}}', {{paramName}} as any);{{/multipartFormData}}{{#multipartFormData}}{{#isPrimitiveType}}{{^isBoolean}}
181
+ localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isBoolean}}{{/isPrimitiveType}}{{#isPrimitiveType}}{{#isBoolean}}
182
+ localVarFormParams.append('{{baseName}}', String({{paramName}}) as any);{{/isBoolean}}{{/isPrimitiveType}}{{^isPrimitiveType}}{{#isEnumRef}}
183
+ localVarFormParams.append('{{baseName}}', {{paramName}} as any);{{/isEnumRef}}{{^isEnumRef}}
184
+ localVarFormParams.append('{{baseName}}', new Blob([JSON.stringify({{paramName}})], { type: "application/json", }));{{/isEnumRef}}{{/isPrimitiveType}}{{/multipartFormData}}
185
+ }{{/isArray}}
186
+ {{/formParams}}{{/vendorExtensions}}
187
+ {{#vendorExtensions}}{{#hasFormParams}}{{^multipartFormData}}
188
+ localVarHeaderParameter['Content-Type'] = 'application/x-www-form-urlencoded';{{/multipartFormData}}{{#multipartFormData}}
189
+ localVarHeaderParameter['Content-Type'] = 'multipart/form-data';{{/multipartFormData}}
190
+ {{/hasFormParams}}{{/vendorExtensions}}
191
+ {{#bodyParam}}
192
+ {{^consumes}}
193
+ localVarHeaderParameter['Content-Type'] = 'application/json';
194
+ {{/consumes}}
195
+ {{#consumes.0}}
196
+ localVarHeaderParameter['Content-Type'] = '{{{mediaType}}}';
197
+ {{/consumes.0}}
198
+
199
+ {{/bodyParam}}
200
+ {{#headerParams}}
201
+ {{#isArray}}
202
+ if ({{paramName}}) {
203
+ {{#uniqueItems}}
204
+ let mapped = Array.from({{paramName}}).map(value => (<any>"{{{dataType}}}" !== "Set<string>") ? JSON.stringify(value) : (value || ""));
205
+ {{/uniqueItems}}
206
+ {{^uniqueItems}}
207
+ let mapped = {{paramName}}.map(value => (<any>"{{{dataType}}}" !== "Array<string>") ? JSON.stringify(value) : (value || ""));
208
+ {{/uniqueItems}}
209
+ localVarHeaderParameter['{{baseName}}'] = mapped.join(COLLECTION_FORMATS["{{collectionFormat}}"]);
210
+ }
211
+ {{/isArray}}
212
+ {{^isArray}}
213
+ {{! `val == null` covers for both `null` and `undefined`}}
214
+ if ({{paramName}} != null) {
215
+ {{#isString}}
216
+ localVarHeaderParameter['{{baseName}}'] = String({{paramName}});
217
+ {{/isString}}
218
+ {{^isString}}
219
+ {{! isString is falsy also for $ref that defines a string or enum type}}
220
+ localVarHeaderParameter['{{baseName}}'] = typeof {{paramName}} === 'string'
221
+ ? {{paramName}}
222
+ : JSON.stringify({{paramName}});
223
+ {{/isString}}
224
+ }
225
+ {{/isArray}}
226
+ {{/headerParams}}
227
+ setSearchParams(localVarUrlObj, localVarQueryParameter);
228
+ let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
229
+ localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions,{{#hasFormParams}}{{#multipartFormData}} ...(localVarFormParams as any).getHeaders?.(),{{/multipartFormData}}{{/hasFormParams}} ...options.headers};
230
+ {{#hasFormParams}}
231
+ localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}};
232
+ {{/hasFormParams}}
233
+ {{#bodyParam}}
234
+ localVarRequestOptions.data = serializeDataIfNeeded({{paramName}}, localVarRequestOptions, configuration)
235
+ {{/bodyParam}}
236
+
237
+ return {
238
+ url: toPathString(localVarUrlObj),
239
+ options: localVarRequestOptions,
240
+ };
241
+ },
242
+ {{/operation}}
243
+ }
244
+ };
245
+
246
+ /**
247
+ * {{classname}} - functional programming interface{{#description}}
248
+ * {{{.}}}{{/description}}
249
+ * @export
250
+ */
251
+ export const {{classname}}Fp = function(configuration?: Configuration) {
252
+ const localVarAxiosParamCreator = {{classname}}AxiosParamCreator(configuration)
253
+ return {
254
+ {{#operation}}
255
+ /**
256
+ * {{&notes}}
257
+ {{#summary}}
258
+ * @summary {{&summary}}
259
+ {{/summary}}
260
+ {{#allParams}}
261
+ * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
262
+ {{/allParams}}
263
+ * @param {*} [options] Override http request option.{{#isDeprecated}}
264
+ * @deprecated{{/isDeprecated}}
265
+ * @throws {RequiredError}
266
+ */
267
+ async {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>> {
268
+ const localVarAxiosArgs = await localVarAxiosParamCreator.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options);
269
+ const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
270
+ const localVarOperationServerBasePath = operationServerMap['{{classname}}.{{nickname}}']?.[localVarOperationServerIndex]?.url;
271
+ {{#returnType}}
272
+ {{^returnTypeIsPrimitive}}
273
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath).then(response => {
274
+ // Check if response transformation is enabled (default: true)
275
+ if (configuration?.enableResponseTransformation !== false) {
276
+ try {
277
+ {{#isArray}}
278
+ response.data = plainToInstance({{returnBaseType}}, response.data as any[]);
279
+ {{/isArray}}
280
+ {{^isArray}}
281
+ response.data = plainToInstance({{returnBaseType}}, response.data);
282
+ {{/isArray}}
283
+ } catch (error) {
284
+ // Handle transformation errors
285
+ if (configuration?.onTransformationError) {
286
+ configuration.onTransformationError(error as Error, {{returnBaseType}}, response.data);
287
+ } else {
288
+ console.error('class-transformer failed to transform response:', error);
289
+ console.error('Returning original response data. To handle this error, provide onTransformationError in Configuration.');
290
+ }
291
+ // Return original data on error (cast for type safety)
292
+ {{#isArray}}
293
+ response.data = response.data as any as {{returnBaseType}}[];
294
+ {{/isArray}}
295
+ {{^isArray}}
296
+ response.data = response.data as any as {{returnBaseType}};
297
+ {{/isArray}}
298
+ }
299
+ }
300
+ return response as AxiosResponse<{{#isArray}}{{returnBaseType}}[]{{/isArray}}{{^isArray}}{{returnBaseType}}{{/isArray}}>;
301
+ });
302
+ {{/returnTypeIsPrimitive}}
303
+ {{#returnTypeIsPrimitive}}
304
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
305
+ {{/returnTypeIsPrimitive}}
306
+ {{/returnType}}
307
+ {{^returnType}}
308
+ return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
309
+ {{/returnType}}
310
+ },
311
+ {{/operation}}
312
+ }
313
+ };
314
+
315
+ /**
316
+ * {{classname}} - factory interface{{#description}}
317
+ * {{&description}}{{/description}}
318
+ * @export
319
+ */
320
+ export const {{classname}}Factory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
321
+ const localVarFp = {{classname}}Fp(configuration)
322
+ return {
323
+ {{#operation}}
324
+ /**
325
+ * {{&notes}}
326
+ {{#summary}}
327
+ * @summary {{&summary}}
328
+ {{/summary}}
329
+ {{#useSingleRequestParameter}}
330
+ {{#allParams.0}}
331
+ * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters.
332
+ {{/allParams.0}}
333
+ {{/useSingleRequestParameter}}
334
+ {{^useSingleRequestParameter}}
335
+ {{#allParams}}
336
+ * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
337
+ {{/allParams}}
338
+ {{/useSingleRequestParameter}}
339
+ * @param {*} [options] Override http request option.{{#isDeprecated}}
340
+ * @deprecated{{/isDeprecated}}
341
+ * @throws {RequiredError}
342
+ */
343
+ {{#useSingleRequestParameter}}
344
+ {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: RawAxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> {
345
+ return localVarFp.{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(axios, basePath));
346
+ },
347
+ {{/useSingleRequestParameter}}
348
+ {{^useSingleRequestParameter}}
349
+ {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: RawAxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}> {
350
+ return localVarFp.{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(axios, basePath));
351
+ },
352
+ {{/useSingleRequestParameter}}
353
+ {{/operation}}
354
+ };
355
+ };
356
+
357
+ {{#withInterfaces}}
358
+ /**
359
+ * {{classname}} - interface{{#description}}
360
+ * {{&description}}{{/description}}
361
+ * @export
362
+ * @interface {{classname}}
363
+ */
364
+ export interface {{classname}}Interface {
365
+ {{#operation}}
366
+ /**
367
+ * {{&notes}}
368
+ {{#summary}}
369
+ * @summary {{&summary}}
370
+ {{/summary}}
371
+ {{#useSingleRequestParameter}}
372
+ {{#allParams.0}}
373
+ * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters.
374
+ {{/allParams.0}}
375
+ {{/useSingleRequestParameter}}
376
+ {{^useSingleRequestParameter}}
377
+ {{#allParams}}
378
+ * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
379
+ {{/allParams}}
380
+ {{/useSingleRequestParameter}}
381
+ * @param {*} [options] Override http request option.{{#isDeprecated}}
382
+ * @deprecated{{/isDeprecated}}
383
+ * @throws {RequiredError}
384
+ * @memberof {{classname}}Interface
385
+ */
386
+ {{#useSingleRequestParameter}}
387
+ {{nickname}}({{#allParams.0}}requestParameters{{^hasRequiredParams}}?{{/hasRequiredParams}}: {{classname}}{{operationIdCamelCase}}Request, {{/allParams.0}}options?: RawAxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>;
388
+ {{/useSingleRequestParameter}}
389
+ {{^useSingleRequestParameter}}
390
+ {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: RawAxiosRequestConfig): AxiosPromise<{{{returnType}}}{{^returnType}}void{{/returnType}}>;
391
+ {{/useSingleRequestParameter}}
392
+
393
+ {{/operation}}
394
+ }
395
+
396
+ {{/withInterfaces}}
397
+ {{#useSingleRequestParameter}}
398
+ {{#operation}}
399
+ {{#allParams.0}}
400
+ /**
401
+ * Request parameters for {{nickname}} operation in {{classname}}.
402
+ * @export
403
+ * @interface {{classname}}{{operationIdCamelCase}}Request
404
+ */
405
+ export interface {{classname}}{{operationIdCamelCase}}Request {
406
+ {{#allParams}}
407
+ /**
408
+ * {{description}}
409
+ * @type {{=<% %>=}}{<%&dataType%>}<%={{ }}=%>
410
+ * @memberof {{classname}}{{operationIdCamelCase}}
411
+ */
412
+ readonly {{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}
413
+ {{^-last}}
414
+
415
+ {{/-last}}
416
+ {{/allParams}}
417
+ }
418
+
419
+ {{/allParams.0}}
420
+ {{/operation}}
421
+ {{/useSingleRequestParameter}}
422
+ /**
423
+ * {{classname}} - object-oriented interface{{#description}}
424
+ * {{{.}}}{{/description}}
425
+ * @export
426
+ * @class {{classname}}
427
+ * @extends {BaseAPI}
428
+ */
429
+ {{#withInterfaces}}
430
+ export class {{classname}} extends BaseAPI implements {{classname}}Interface {
431
+ {{/withInterfaces}}
432
+ {{^withInterfaces}}
433
+ export class {{classname}} extends BaseAPI {
434
+ {{/withInterfaces}}
435
+ {{#operation}}
436
+ /**
437
+ * {{&notes}}
438
+ {{#summary}}
439
+ * @summary {{&summary}}
440
+ {{/summary}}
441
+ {{#useSingleRequestParameter}}
442
+ {{#allParams.0}}
443
+ * @param {{=<% %>=}}{<%& classname %><%& operationIdCamelCase %>Request}<%={{ }}=%> requestParameters Request parameters.
444
+ {{/allParams.0}}
445
+ {{/useSingleRequestParameter}}
446
+ {{^useSingleRequestParameter}}
447
+ {{#allParams}}
448
+ * @param {{=<% %>=}}{<%#isEnum%><%&datatypeWithEnum%><%/isEnum%><%^isEnum%><%&dataType%><%#isNullable%> | null<%/isNullable%><%/isEnum%>}<%={{ }}=%> {{^required}}[{{/required}}{{paramName}}{{^required}}]{{/required}} {{description}}
449
+ {{/allParams}}
450
+ {{/useSingleRequestParameter}}
451
+ * @param {*} [options] Override http request option.{{#isDeprecated}}
452
+ * @deprecated{{/isDeprecated}}
453
+ * @throws {RequiredError}
454
+ * @memberof {{classname}}
455
+ */
456
+ {{#useSingleRequestParameter}}
457
+ public {{nickname}}({{#allParams.0}}requestParameters: {{classname}}{{operationIdCamelCase}}Request{{^hasRequiredParams}} = {}{{/hasRequiredParams}}, {{/allParams.0}}options?: RawAxiosRequestConfig) {
458
+ return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams.0}}{{#allParams}}requestParameters.{{paramName}}, {{/allParams}}{{/allParams.0}}options).then((request) => request(this.axios, this.basePath));
459
+ }
460
+ {{/useSingleRequestParameter}}
461
+ {{^useSingleRequestParameter}}
462
+ public {{nickname}}({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}}, {{/allParams}}options?: RawAxiosRequestConfig) {
463
+ return {{classname}}Fp(this.configuration).{{nickname}}({{#allParams}}{{paramName}}, {{/allParams}}options).then((request) => request(this.axios, this.basePath));
464
+ }
465
+ {{/useSingleRequestParameter}}
466
+ {{^-last}}
467
+
468
+ {{/-last}}
469
+ {{/operation}}
470
+ }
471
+ {{/operations}}
472
+
473
+ {{#operations}}
474
+ {{#operation}}
475
+ {{#allParams}}
476
+ {{#isEnum}}
477
+ {{#stringEnums}}
478
+ /**
479
+ * @export
480
+ * @enum {string}
481
+ */
482
+ export enum {{operationIdCamelCase}}{{enumName}} {
483
+ {{#allowableValues}}
484
+ {{#enumVars}}
485
+ {{{name}}} = {{{value}}}{{^-last}},{{/-last}}
486
+ {{/enumVars}}
487
+ {{/allowableValues}}
488
+ }
489
+ {{/stringEnums}}
490
+ {{^stringEnums}}
491
+ /**
492
+ * @export
493
+ */
494
+ export const {{operationIdCamelCase}}{{enumName}} = {
495
+ {{#allowableValues}}
496
+ {{#enumVars}}
497
+ {{{name}}}: {{{value}}}{{^-last}},{{/-last}}
498
+ {{/enumVars}}
499
+ {{/allowableValues}}
500
+ } as const;
501
+ export type {{operationIdCamelCase}}{{enumName}} = typeof {{operationIdCamelCase}}{{enumName}}[keyof typeof {{operationIdCamelCase}}{{enumName}}];
502
+ {{/stringEnums}}
503
+ {{/isEnum}}
504
+ {{/allParams}}
505
+ {{/operation}}
506
+ {{/operations}}
@@ -0,0 +1,144 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ {{>licenseInfo}}
4
+
5
+ export interface ConfigurationParameters {
6
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
7
+ username?: string;
8
+ password?: string;
9
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
10
+ basePath?: string;
11
+ serverIndex?: number;
12
+ baseOptions?: any;
13
+ formDataCtor?: new () => any;
14
+ /**
15
+ * Enable automatic transformation of API responses to class instances using class-transformer.
16
+ * When enabled (default), responses are converted to class instances with decorators applied.
17
+ * When disabled, responses remain as plain JSON objects.
18
+ * @default true
19
+ */
20
+ enableResponseTransformation?: boolean;
21
+ /**
22
+ * Custom error handler for class-transformer failures.
23
+ * Called when plainToInstance throws an error during response transformation.
24
+ * If not provided, errors are logged to console and the original response data is returned.
25
+ * @param error - The error thrown by class-transformer
26
+ * @param modelClass - The class that was being instantiated
27
+ * @param data - The raw response data
28
+ */
29
+ onTransformationError?: (error: Error, modelClass: any, data: any) => void;
30
+ }
31
+
32
+ export class Configuration {
33
+ /**
34
+ * parameter for apiKey security
35
+ * @param name security name
36
+ * @memberof Configuration
37
+ */
38
+ apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
39
+ /**
40
+ * parameter for basic security
41
+ *
42
+ * @type {string}
43
+ * @memberof Configuration
44
+ */
45
+ username?: string;
46
+ /**
47
+ * parameter for basic security
48
+ *
49
+ * @type {string}
50
+ * @memberof Configuration
51
+ */
52
+ password?: string;
53
+ /**
54
+ * parameter for oauth2 security
55
+ * @param name security name
56
+ * @param scopes oauth2 scope
57
+ * @memberof Configuration
58
+ */
59
+ accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
60
+ /**
61
+ * override base path
62
+ *
63
+ * @type {string}
64
+ * @memberof Configuration
65
+ */
66
+ basePath?: string;
67
+ /**
68
+ * override server index
69
+ *
70
+ * @type {number}
71
+ * @memberof Configuration
72
+ */
73
+ serverIndex?: number;
74
+ /**
75
+ * base options for axios calls
76
+ *
77
+ * @type {any}
78
+ * @memberof Configuration
79
+ */
80
+ baseOptions?: any;
81
+ /**
82
+ * The FormData constructor that will be used to create multipart form data
83
+ * requests. You can inject this here so that execution environments that
84
+ * do not support the FormData class can still run the generated client.
85
+ *
86
+ * @type {new () => FormData}
87
+ */
88
+ formDataCtor?: new () => any;
89
+ /**
90
+ * Enable automatic transformation of API responses to class instances using class-transformer.
91
+ * When enabled (default), responses are converted to class instances with decorators applied.
92
+ * When disabled, responses remain as plain JSON objects.
93
+ *
94
+ * @type {boolean}
95
+ * @memberof Configuration
96
+ * @default true
97
+ */
98
+ enableResponseTransformation?: boolean;
99
+ /**
100
+ * Custom error handler for class-transformer failures.
101
+ * Called when plainToInstance throws an error during response transformation.
102
+ * If not provided, errors are logged to console and the original response data is returned.
103
+ *
104
+ * @type {(error: Error, modelClass: any, data: any) => void}
105
+ * @memberof Configuration
106
+ */
107
+ onTransformationError?: (error: Error, modelClass: any, data: any) => void;
108
+
109
+ constructor(param: ConfigurationParameters = {}) {
110
+ this.apiKey = param.apiKey;
111
+ this.username = param.username;
112
+ this.password = param.password;
113
+ this.accessToken = param.accessToken;
114
+ this.basePath = param.basePath;
115
+ this.serverIndex = param.serverIndex;
116
+ this.baseOptions = {
117
+ ...param.baseOptions,
118
+ headers: {
119
+ {{#httpUserAgent}}
120
+ 'User-Agent': "{{httpUserAgent}}",
121
+ {{/httpUserAgent}}
122
+ ...param.baseOptions?.headers,
123
+ },
124
+ };
125
+ this.formDataCtor = param.formDataCtor;
126
+ this.enableResponseTransformation = param.enableResponseTransformation ?? true;
127
+ this.onTransformationError = param.onTransformationError;
128
+ }
129
+
130
+ /**
131
+ * Check if the given MIME is a JSON MIME.
132
+ * JSON MIME examples:
133
+ * application/json
134
+ * application/json; charset=UTF8
135
+ * APPLICATION/JSON
136
+ * application/vnd.company+json
137
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
138
+ * @return True if the given MIME is JSON, false otherwise.
139
+ */
140
+ public isJsonMime(mime: string): boolean {
141
+ const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
142
+ return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
143
+ }
144
+ }