klasik 1.0.11 → 1.0.12
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 +4 -2
- package/test-discriminated-output/.openapi-generator-ignore +23 -0
- package/test-discriminated-output/api/default-api.ts +142 -0
- package/test-discriminated-output/api.ts +19 -0
- package/test-discriminated-output/base.ts +86 -0
- package/test-discriminated-output/common.ts +151 -0
- package/test-discriminated-output/configuration.ts +152 -0
- package/test-discriminated-output/index.ts +18 -0
- package/test-discriminated-output/models/capability.js +80 -0
- package/test-discriminated-output/models/capability.ts +74 -0
- package/test-discriminated-output/models/helm-component.js +82 -0
- package/test-discriminated-output/models/helm-component.ts +83 -0
- package/test-discriminated-output/models/index.ts +4 -0
- package/test-discriminated-output/models/kustomize-component.js +70 -0
- package/test-discriminated-output/models/kustomize-component.ts +70 -0
- package/test-discriminated-output/models/manifest-component.js +58 -0
- package/test-discriminated-output/models/manifest-component.ts +57 -0
- package/test-runtime.js +72 -0
- package/test-runtime.ts +80 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "klasik",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Download OpenAPI specs from remote URLs and generate TypeScript clients with class-transformer support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -26,8 +26,10 @@
|
|
|
26
26
|
"license": "MIT",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"axios": "^1.6.0",
|
|
29
|
+
"class-transformer": "^0.5.1",
|
|
29
30
|
"commander": "^11.0.0",
|
|
30
|
-
"openapi-class-transformer": "1.0.
|
|
31
|
+
"openapi-class-transformer": "^1.0.11",
|
|
32
|
+
"reflect-metadata": "^0.2.2"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@types/jest": "^29.5.0",
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# OpenAPI Generator Ignore
|
|
2
|
+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
|
3
|
+
|
|
4
|
+
# Use this file to prevent files from being overwritten by the generator.
|
|
5
|
+
# The patterns follow closely to .gitignore or .dockerignore.
|
|
6
|
+
|
|
7
|
+
# As an example, the C# client generator defines ApiClient.cs.
|
|
8
|
+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
|
9
|
+
#ApiClient.cs
|
|
10
|
+
|
|
11
|
+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
|
12
|
+
#foo/*/qux
|
|
13
|
+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
|
14
|
+
|
|
15
|
+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
|
16
|
+
#foo/**/qux
|
|
17
|
+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
|
18
|
+
|
|
19
|
+
# You can also negate patterns with an exclamation (!).
|
|
20
|
+
# For example, you can ignore all files in a docs folder with the file extension .md:
|
|
21
|
+
#docs/*.md
|
|
22
|
+
# Then explicitly reverse the ignore rule for a single file:
|
|
23
|
+
#!docs/README.md
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Test API with Discriminated Unions
|
|
5
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import type { Configuration } from '../configuration.js';
|
|
17
|
+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
18
|
+
import globalAxios, { type AxiosResponse } from 'axios';
|
|
19
|
+
import { plainToInstance } from 'class-transformer';
|
|
20
|
+
// URLSearchParams not necessarily used
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
import { URL, URLSearchParams } from 'url';
|
|
23
|
+
// Some imports not used depending on template conditions
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common.js';
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base.js';
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
import { Capability } from '../models/index.js';
|
|
30
|
+
/**
|
|
31
|
+
* DefaultApi - axios parameter creator
|
|
32
|
+
* @export
|
|
33
|
+
*/
|
|
34
|
+
export const DefaultApiAxiosParamCreator = function (configuration?: Configuration) {
|
|
35
|
+
return {
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {*} [options] Override http request option.
|
|
39
|
+
* @throws {RequiredError}
|
|
40
|
+
*/
|
|
41
|
+
getCapabilities: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
42
|
+
const localVarPath = `/capabilities`;
|
|
43
|
+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
|
|
44
|
+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
|
|
45
|
+
let baseOptions;
|
|
46
|
+
if (configuration) {
|
|
47
|
+
baseOptions = configuration.baseOptions;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
|
|
51
|
+
const localVarHeaderParameter = {} as any;
|
|
52
|
+
const localVarQueryParameter = {} as any;
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
setSearchParams(localVarUrlObj, localVarQueryParameter);
|
|
57
|
+
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
|
|
58
|
+
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
url: toPathString(localVarUrlObj),
|
|
62
|
+
options: localVarRequestOptions,
|
|
63
|
+
};
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* DefaultApi - functional programming interface
|
|
70
|
+
* @export
|
|
71
|
+
*/
|
|
72
|
+
export const DefaultApiFp = function(configuration?: Configuration) {
|
|
73
|
+
const localVarAxiosParamCreator = DefaultApiAxiosParamCreator(configuration)
|
|
74
|
+
return {
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param {*} [options] Override http request option.
|
|
78
|
+
* @throws {RequiredError}
|
|
79
|
+
*/
|
|
80
|
+
async getCapabilities(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Capability>>> {
|
|
81
|
+
const localVarAxiosArgs = await localVarAxiosParamCreator.getCapabilities(options);
|
|
82
|
+
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
|
|
83
|
+
const localVarOperationServerBasePath = operationServerMap['DefaultApi.getCapabilities']?.[localVarOperationServerIndex]?.url;
|
|
84
|
+
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath).then(response => {
|
|
85
|
+
// Check if response transformation is enabled (default: true)
|
|
86
|
+
if (configuration?.enableResponseTransformation !== false) {
|
|
87
|
+
try {
|
|
88
|
+
response.data = plainToInstance(Capability, response.data as any[]);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
// Handle transformation errors
|
|
91
|
+
if (configuration?.onTransformationError) {
|
|
92
|
+
configuration.onTransformationError(error as Error, Capability, response.data);
|
|
93
|
+
} else {
|
|
94
|
+
console.error('class-transformer failed to transform response:', error);
|
|
95
|
+
console.error('Returning original response data. To handle this error, provide onTransformationError in Configuration.');
|
|
96
|
+
}
|
|
97
|
+
// Return original data on error (cast for type safety)
|
|
98
|
+
response.data = response.data as any as Capability[];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return response as AxiosResponse<Capability[]>;
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* DefaultApi - factory interface
|
|
109
|
+
* @export
|
|
110
|
+
*/
|
|
111
|
+
export const DefaultApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
|
|
112
|
+
const localVarFp = DefaultApiFp(configuration)
|
|
113
|
+
return {
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @param {*} [options] Override http request option.
|
|
117
|
+
* @throws {RequiredError}
|
|
118
|
+
*/
|
|
119
|
+
getCapabilities(options?: RawAxiosRequestConfig): AxiosPromise<Array<Capability>> {
|
|
120
|
+
return localVarFp.getCapabilities(options).then((request) => request(axios, basePath));
|
|
121
|
+
},
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* DefaultApi - object-oriented interface
|
|
127
|
+
* @export
|
|
128
|
+
* @class DefaultApi
|
|
129
|
+
* @extends {BaseAPI}
|
|
130
|
+
*/
|
|
131
|
+
export class DefaultApi extends BaseAPI {
|
|
132
|
+
/**
|
|
133
|
+
*
|
|
134
|
+
* @param {*} [options] Override http request option.
|
|
135
|
+
* @throws {RequiredError}
|
|
136
|
+
* @memberof DefaultApi
|
|
137
|
+
*/
|
|
138
|
+
public getCapabilities(options?: RawAxiosRequestConfig) {
|
|
139
|
+
return DefaultApiFp(this.configuration).getCapabilities(options).then((request) => request(this.axios, this.basePath));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Test API with Discriminated Unions
|
|
5
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
export { Configuration } from './configuration.js';
|
|
18
|
+
export * from './api/default-api.js';
|
|
19
|
+
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Test API with Discriminated Unions
|
|
5
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import type { Configuration } from './configuration.js';
|
|
17
|
+
// Some imports not used depending on template conditions
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
20
|
+
import globalAxios from 'axios';
|
|
21
|
+
|
|
22
|
+
export const BASE_PATH = "https://api.example.com".replace(/\/+$/, "");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
*/
|
|
28
|
+
export const COLLECTION_FORMATS = {
|
|
29
|
+
csv: ",",
|
|
30
|
+
ssv: " ",
|
|
31
|
+
tsv: "\t",
|
|
32
|
+
pipes: "|",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
* @interface RequestArgs
|
|
39
|
+
*/
|
|
40
|
+
export interface RequestArgs {
|
|
41
|
+
url: string;
|
|
42
|
+
options: RawAxiosRequestConfig;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @export
|
|
48
|
+
* @class BaseAPI
|
|
49
|
+
*/
|
|
50
|
+
export class BaseAPI {
|
|
51
|
+
protected configuration: Configuration | undefined;
|
|
52
|
+
|
|
53
|
+
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
54
|
+
if (configuration) {
|
|
55
|
+
this.configuration = configuration;
|
|
56
|
+
this.basePath = configuration.basePath ?? basePath;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @export
|
|
64
|
+
* @class RequiredError
|
|
65
|
+
* @extends {Error}
|
|
66
|
+
*/
|
|
67
|
+
export class RequiredError extends Error {
|
|
68
|
+
constructor(public field: string, msg?: string) {
|
|
69
|
+
super(msg);
|
|
70
|
+
this.name = "RequiredError"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface ServerMap {
|
|
75
|
+
[key: string]: {
|
|
76
|
+
url: string,
|
|
77
|
+
description: string,
|
|
78
|
+
}[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @export
|
|
84
|
+
*/
|
|
85
|
+
export const operationServerMap: ServerMap = {
|
|
86
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Test API with Discriminated Unions
|
|
5
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import type { Configuration } from "./configuration.js";
|
|
17
|
+
import type { RequestArgs } from "./base.js";
|
|
18
|
+
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
19
|
+
import { RequiredError } from "./base.js";
|
|
20
|
+
import { URL, URLSearchParams } from 'url';
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @export
|
|
25
|
+
*/
|
|
26
|
+
export const DUMMY_BASE_URL = 'https://example.com'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @throws {RequiredError}
|
|
31
|
+
* @export
|
|
32
|
+
*/
|
|
33
|
+
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
|
34
|
+
if (paramValue === null || paramValue === undefined) {
|
|
35
|
+
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @export
|
|
42
|
+
*/
|
|
43
|
+
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
|
|
44
|
+
if (configuration && configuration.apiKey) {
|
|
45
|
+
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
46
|
+
? await configuration.apiKey(keyParamName)
|
|
47
|
+
: await configuration.apiKey;
|
|
48
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
*
|
|
54
|
+
* @export
|
|
55
|
+
*/
|
|
56
|
+
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
|
|
57
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
58
|
+
object["auth"] = { username: configuration.username, password: configuration.password };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
*
|
|
64
|
+
* @export
|
|
65
|
+
*/
|
|
66
|
+
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
|
|
67
|
+
if (configuration && configuration.accessToken) {
|
|
68
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
69
|
+
? await configuration.accessToken()
|
|
70
|
+
: await configuration.accessToken;
|
|
71
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @export
|
|
78
|
+
*/
|
|
79
|
+
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
|
|
80
|
+
if (configuration && configuration.accessToken) {
|
|
81
|
+
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
|
82
|
+
? await configuration.accessToken(name, scopes)
|
|
83
|
+
: await configuration.accessToken;
|
|
84
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
|
|
89
|
+
if (parameter == null) return;
|
|
90
|
+
if (typeof parameter === "object") {
|
|
91
|
+
if (Array.isArray(parameter)) {
|
|
92
|
+
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
Object.keys(parameter).forEach(currentKey =>
|
|
96
|
+
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (urlSearchParams.has(key)) {
|
|
102
|
+
urlSearchParams.append(key, parameter);
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
urlSearchParams.set(key, parameter);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
*
|
|
112
|
+
* @export
|
|
113
|
+
*/
|
|
114
|
+
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
|
115
|
+
const searchParams = new URLSearchParams(url.search);
|
|
116
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
117
|
+
url.search = searchParams.toString();
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
*
|
|
122
|
+
* @export
|
|
123
|
+
*/
|
|
124
|
+
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
|
125
|
+
const nonString = typeof value !== 'string';
|
|
126
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
127
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
128
|
+
: nonString;
|
|
129
|
+
return needsSerialization
|
|
130
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
131
|
+
: (value || "");
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
*
|
|
136
|
+
* @export
|
|
137
|
+
*/
|
|
138
|
+
export const toPathString = function (url: URL) {
|
|
139
|
+
return url.pathname + url.search + url.hash
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
*
|
|
144
|
+
* @export
|
|
145
|
+
*/
|
|
146
|
+
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
|
147
|
+
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
148
|
+
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
|
|
149
|
+
return axios.request<T, R>(axiosRequestArgs);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Test API with Discriminated Unions
|
|
5
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export interface ConfigurationParameters {
|
|
17
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
18
|
+
username?: string;
|
|
19
|
+
password?: string;
|
|
20
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
21
|
+
basePath?: string;
|
|
22
|
+
serverIndex?: number;
|
|
23
|
+
baseOptions?: any;
|
|
24
|
+
formDataCtor?: new () => any;
|
|
25
|
+
/**
|
|
26
|
+
* Enable automatic transformation of API responses to class instances using class-transformer.
|
|
27
|
+
* When enabled (default), responses are converted to class instances with decorators applied.
|
|
28
|
+
* When disabled, responses remain as plain JSON objects.
|
|
29
|
+
* @default true
|
|
30
|
+
*/
|
|
31
|
+
enableResponseTransformation?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Custom error handler for class-transformer failures.
|
|
34
|
+
* Called when plainToInstance throws an error during response transformation.
|
|
35
|
+
* If not provided, errors are logged to console and the original response data is returned.
|
|
36
|
+
* @param error - The error thrown by class-transformer
|
|
37
|
+
* @param modelClass - The class that was being instantiated
|
|
38
|
+
* @param data - The raw response data
|
|
39
|
+
*/
|
|
40
|
+
onTransformationError?: (error: Error, modelClass: any, data: any) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class Configuration {
|
|
44
|
+
/**
|
|
45
|
+
* parameter for apiKey security
|
|
46
|
+
* @param name security name
|
|
47
|
+
* @memberof Configuration
|
|
48
|
+
*/
|
|
49
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
50
|
+
/**
|
|
51
|
+
* parameter for basic security
|
|
52
|
+
*
|
|
53
|
+
* @type {string}
|
|
54
|
+
* @memberof Configuration
|
|
55
|
+
*/
|
|
56
|
+
username?: string;
|
|
57
|
+
/**
|
|
58
|
+
* parameter for basic security
|
|
59
|
+
*
|
|
60
|
+
* @type {string}
|
|
61
|
+
* @memberof Configuration
|
|
62
|
+
*/
|
|
63
|
+
password?: string;
|
|
64
|
+
/**
|
|
65
|
+
* parameter for oauth2 security
|
|
66
|
+
* @param name security name
|
|
67
|
+
* @param scopes oauth2 scope
|
|
68
|
+
* @memberof Configuration
|
|
69
|
+
*/
|
|
70
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
71
|
+
/**
|
|
72
|
+
* override base path
|
|
73
|
+
*
|
|
74
|
+
* @type {string}
|
|
75
|
+
* @memberof Configuration
|
|
76
|
+
*/
|
|
77
|
+
basePath?: string;
|
|
78
|
+
/**
|
|
79
|
+
* override server index
|
|
80
|
+
*
|
|
81
|
+
* @type {number}
|
|
82
|
+
* @memberof Configuration
|
|
83
|
+
*/
|
|
84
|
+
serverIndex?: number;
|
|
85
|
+
/**
|
|
86
|
+
* base options for axios calls
|
|
87
|
+
*
|
|
88
|
+
* @type {any}
|
|
89
|
+
* @memberof Configuration
|
|
90
|
+
*/
|
|
91
|
+
baseOptions?: any;
|
|
92
|
+
/**
|
|
93
|
+
* The FormData constructor that will be used to create multipart form data
|
|
94
|
+
* requests. You can inject this here so that execution environments that
|
|
95
|
+
* do not support the FormData class can still run the generated client.
|
|
96
|
+
*
|
|
97
|
+
* @type {new () => FormData}
|
|
98
|
+
*/
|
|
99
|
+
formDataCtor?: new () => any;
|
|
100
|
+
/**
|
|
101
|
+
* Enable automatic transformation of API responses to class instances using class-transformer.
|
|
102
|
+
* When enabled (default), responses are converted to class instances with decorators applied.
|
|
103
|
+
* When disabled, responses remain as plain JSON objects.
|
|
104
|
+
*
|
|
105
|
+
* @type {boolean}
|
|
106
|
+
* @memberof Configuration
|
|
107
|
+
* @default true
|
|
108
|
+
*/
|
|
109
|
+
enableResponseTransformation?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Custom error handler for class-transformer failures.
|
|
112
|
+
* Called when plainToInstance throws an error during response transformation.
|
|
113
|
+
* If not provided, errors are logged to console and the original response data is returned.
|
|
114
|
+
*
|
|
115
|
+
* @type {(error: Error, modelClass: any, data: any) => void}
|
|
116
|
+
* @memberof Configuration
|
|
117
|
+
*/
|
|
118
|
+
onTransformationError?: (error: Error, modelClass: any, data: any) => void;
|
|
119
|
+
|
|
120
|
+
constructor(param: ConfigurationParameters = {}) {
|
|
121
|
+
this.apiKey = param.apiKey;
|
|
122
|
+
this.username = param.username;
|
|
123
|
+
this.password = param.password;
|
|
124
|
+
this.accessToken = param.accessToken;
|
|
125
|
+
this.basePath = param.basePath;
|
|
126
|
+
this.serverIndex = param.serverIndex;
|
|
127
|
+
this.baseOptions = {
|
|
128
|
+
...param.baseOptions,
|
|
129
|
+
headers: {
|
|
130
|
+
...param.baseOptions?.headers,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
this.formDataCtor = param.formDataCtor;
|
|
134
|
+
this.enableResponseTransformation = param.enableResponseTransformation ?? true;
|
|
135
|
+
this.onTransformationError = param.onTransformationError;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Check if the given MIME is a JSON MIME.
|
|
140
|
+
* JSON MIME examples:
|
|
141
|
+
* application/json
|
|
142
|
+
* application/json; charset=UTF8
|
|
143
|
+
* APPLICATION/JSON
|
|
144
|
+
* application/vnd.company+json
|
|
145
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
146
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
147
|
+
*/
|
|
148
|
+
public isJsonMime(mime: string): boolean {
|
|
149
|
+
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
150
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Test API with Discriminated Unions
|
|
5
|
+
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.0.0
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export * from "./api.js";
|
|
17
|
+
export * from "./configuration.js";
|
|
18
|
+
export * from "./models/index.js";
|