@kubb/plugin-client 3.5.3 → 3.5.5
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/{src/clients → clients}/axios.ts +5 -4
- package/{src/clients → clients}/fetch.ts +5 -4
- package/dist/{chunk-A2RSM7BK.js → chunk-7B6Q2VE7.js} +3 -3
- package/dist/{chunk-A2RSM7BK.js.map → chunk-7B6Q2VE7.js.map} +1 -1
- package/dist/{chunk-CB7AGPWV.js → chunk-HT47HSI2.js} +14 -9
- package/dist/chunk-HT47HSI2.js.map +1 -0
- package/dist/{chunk-36TRCKLD.cjs → chunk-LR36WFYS.cjs} +14 -9
- package/dist/chunk-LR36WFYS.cjs.map +1 -0
- package/dist/{chunk-6VFJH3L2.cjs → chunk-MR22J6SW.cjs} +6 -6
- package/dist/{chunk-6VFJH3L2.cjs.map → chunk-MR22J6SW.cjs.map} +1 -1
- package/dist/clients/axios.cjs +6 -6
- package/dist/clients/axios.cjs.map +1 -1
- package/dist/clients/axios.d.cts +2 -2
- package/dist/clients/axios.d.ts +2 -2
- package/dist/clients/axios.js +6 -6
- package/dist/clients/axios.js.map +1 -1
- package/dist/clients/fetch.cjs +6 -6
- package/dist/clients/fetch.cjs.map +1 -1
- package/dist/clients/fetch.d.cts +2 -2
- package/dist/clients/fetch.d.ts +2 -2
- package/dist/clients/fetch.js +6 -6
- package/dist/clients/fetch.js.map +1 -1
- package/dist/components.cjs +4 -4
- package/dist/components.d.cts +3 -1
- package/dist/components.d.ts +3 -1
- package/dist/components.js +1 -1
- package/dist/generators.cjs +5 -5
- package/dist/generators.js +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.js +2 -2
- package/package.json +11 -10
- package/src/components/Client.tsx +19 -7
- package/src/generators/__snapshots__/deletePet.ts +10 -4
- package/src/generators/__snapshots__/deletePetObject.ts +10 -4
- package/src/generators/__snapshots__/findByTags.ts +5 -3
- package/src/generators/__snapshots__/findByTagsFull.ts +5 -3
- package/src/generators/__snapshots__/findByTagsObject.ts +5 -3
- package/src/generators/__snapshots__/findByTagsWithZod.ts +5 -3
- package/src/generators/__snapshots__/findByTagsWithZodFull.ts +5 -3
- package/src/generators/__snapshots__/importPath.ts +5 -3
- package/src/generators/__snapshots__/updatePetById.ts +5 -3
- package/dist/chunk-36TRCKLD.cjs.map +0 -1
- package/dist/chunk-CB7AGPWV.js.map +0 -1
package/dist/clients/fetch.cjs
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
var
|
|
5
|
+
// clients/fetch.ts
|
|
6
|
+
var client = async (config) => {
|
|
7
7
|
const url = new URL(config.url || "", config.baseURL ? new URL(config.baseURL) : void 0);
|
|
8
8
|
Object.entries(config.params || {}).forEach(([key, value]) => {
|
|
9
9
|
if (value !== void 0) {
|
|
@@ -24,15 +24,15 @@ var fetchClient = async (config) => {
|
|
|
24
24
|
headers: response.headers
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
client.getConfig = () => {
|
|
28
28
|
throw new Error("Not supported");
|
|
29
29
|
};
|
|
30
|
-
|
|
30
|
+
client.setConfig = () => {
|
|
31
31
|
throw new Error("Not supported");
|
|
32
32
|
};
|
|
33
|
-
var fetch_default =
|
|
33
|
+
var fetch_default = client;
|
|
34
34
|
|
|
35
|
+
exports.client = client;
|
|
35
36
|
exports.default = fetch_default;
|
|
36
|
-
exports.fetchClient = fetchClient;
|
|
37
37
|
//# sourceMappingURL=fetch.cjs.map
|
|
38
38
|
//# sourceMappingURL=fetch.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../
|
|
1
|
+
{"version":3,"sources":["../../clients/fetch.ts"],"names":[],"mappings":";;;;;AA0Ba,IAAA,MAAA,GAAS,OAAsD,MAAsE,KAAA;AAChJ,EAAA,MAAM,GAAM,GAAA,IAAI,GAAI,CA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aAAQ,GAAA","file":"fetch.cjs","sourcesContent":["/**\n * Subset of FetchRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: [string, string][] | Record<string, string>\n}\n\n/**\n * Subset of FetchResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers: Headers\n}\n\nexport type ResponseErrorConfig<TError = unknown> = TError\n\nexport const client = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const url = new URL(config.url || '', config.baseURL ? new URL(config.baseURL) : undefined)\n\n Object.entries(config.params || {}).forEach(([key, value]) => {\n if (value !== undefined) {\n url.searchParams.append(key, value === null ? 'null' : value.toString())\n }\n })\n\n const response = await fetch(url.toString(), {\n method: config.method.toUpperCase(),\n body: JSON.stringify(config.data),\n signal: config.signal,\n headers: config.headers,\n })\n\n const data = [204, 205, 304].includes(response.status) || !response.body ? {} : await response.json()\n\n return {\n data: data as TData,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers as Headers,\n }\n}\n\nclient.getConfig = () => {\n throw new Error('Not supported')\n}\nclient.setConfig = () => {\n throw new Error('Not supported')\n}\n\nexport default client\n"]}
|
package/dist/clients/fetch.d.cts
CHANGED
|
@@ -21,10 +21,10 @@ type ResponseConfig<TData = unknown> = {
|
|
|
21
21
|
headers: Headers;
|
|
22
22
|
};
|
|
23
23
|
type ResponseErrorConfig<TError = unknown> = TError;
|
|
24
|
-
declare const
|
|
24
|
+
declare const client: {
|
|
25
25
|
<TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>>;
|
|
26
26
|
getConfig(): never;
|
|
27
27
|
setConfig(): never;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export { type RequestConfig, type ResponseConfig, type ResponseErrorConfig,
|
|
30
|
+
export { type RequestConfig, type ResponseConfig, type ResponseErrorConfig, client, client as default };
|
package/dist/clients/fetch.d.ts
CHANGED
|
@@ -21,10 +21,10 @@ type ResponseConfig<TData = unknown> = {
|
|
|
21
21
|
headers: Headers;
|
|
22
22
|
};
|
|
23
23
|
type ResponseErrorConfig<TError = unknown> = TError;
|
|
24
|
-
declare const
|
|
24
|
+
declare const client: {
|
|
25
25
|
<TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>>;
|
|
26
26
|
getConfig(): never;
|
|
27
27
|
setConfig(): never;
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
export { type RequestConfig, type ResponseConfig, type ResponseErrorConfig,
|
|
30
|
+
export { type RequestConfig, type ResponseConfig, type ResponseErrorConfig, client, client as default };
|
package/dist/clients/fetch.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
var
|
|
1
|
+
// clients/fetch.ts
|
|
2
|
+
var client = async (config) => {
|
|
3
3
|
const url = new URL(config.url || "", config.baseURL ? new URL(config.baseURL) : void 0);
|
|
4
4
|
Object.entries(config.params || {}).forEach(([key, value]) => {
|
|
5
5
|
if (value !== void 0) {
|
|
@@ -20,14 +20,14 @@ var fetchClient = async (config) => {
|
|
|
20
20
|
headers: response.headers
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
|
-
|
|
23
|
+
client.getConfig = () => {
|
|
24
24
|
throw new Error("Not supported");
|
|
25
25
|
};
|
|
26
|
-
|
|
26
|
+
client.setConfig = () => {
|
|
27
27
|
throw new Error("Not supported");
|
|
28
28
|
};
|
|
29
|
-
var fetch_default =
|
|
29
|
+
var fetch_default = client;
|
|
30
30
|
|
|
31
|
-
export { fetch_default as default
|
|
31
|
+
export { client, fetch_default as default };
|
|
32
32
|
//# sourceMappingURL=fetch.js.map
|
|
33
33
|
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IACrB,SAAS,QAAS,CAAA;AAAA,GACpB;AACF;AAEA,MAAA,CAAO,YAAY,MAAM;AACvB,EAAM,MAAA,IAAI,MAAM,eAAe,CAAA;AACjC,CAAA;AACA,MAAA,CAAO,YAAY,MAAM;AACvB,EAAM,MAAA,IAAI,MAAM,eAAe,CAAA;AACjC,CAAA;AAEA,IAAO,aAAQ,GAAA","file":"fetch.js","sourcesContent":["/**\n * Subset of FetchRequestConfig\n */\nexport type RequestConfig<TData = unknown> = {\n baseURL?: string\n url?: string\n method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS'\n params?: unknown\n data?: TData | FormData\n responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'\n signal?: AbortSignal\n headers?: [string, string][] | Record<string, string>\n}\n\n/**\n * Subset of FetchResponse\n */\nexport type ResponseConfig<TData = unknown> = {\n data: TData\n status: number\n statusText: string\n headers: Headers\n}\n\nexport type ResponseErrorConfig<TError = unknown> = TError\n\nexport const client = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {\n const url = new URL(config.url || '', config.baseURL ? new URL(config.baseURL) : undefined)\n\n Object.entries(config.params || {}).forEach(([key, value]) => {\n if (value !== undefined) {\n url.searchParams.append(key, value === null ? 'null' : value.toString())\n }\n })\n\n const response = await fetch(url.toString(), {\n method: config.method.toUpperCase(),\n body: JSON.stringify(config.data),\n signal: config.signal,\n headers: config.headers,\n })\n\n const data = [204, 205, 304].includes(response.status) || !response.body ? {} : await response.json()\n\n return {\n data: data as TData,\n status: response.status,\n statusText: response.statusText,\n headers: response.headers as Headers,\n }\n}\n\nclient.getConfig = () => {\n throw new Error('Not supported')\n}\nclient.setConfig = () => {\n throw new Error('Not supported')\n}\n\nexport default client\n"]}
|
package/dist/components.cjs
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkLR36WFYS_cjs = require('./chunk-LR36WFYS.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "Client", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkLR36WFYS_cjs.Client; }
|
|
10
10
|
});
|
|
11
11
|
Object.defineProperty(exports, "Operations", {
|
|
12
12
|
enumerable: true,
|
|
13
|
-
get: function () { return
|
|
13
|
+
get: function () { return chunkLR36WFYS_cjs.Operations; }
|
|
14
14
|
});
|
|
15
15
|
Object.defineProperty(exports, "Url", {
|
|
16
16
|
enumerable: true,
|
|
17
|
-
get: function () { return
|
|
17
|
+
get: function () { return chunkLR36WFYS_cjs.Url; }
|
|
18
18
|
});
|
|
19
19
|
//# sourceMappingURL=components.cjs.map
|
|
20
20
|
//# sourceMappingURL=components.cjs.map
|
package/dist/components.d.cts
CHANGED
|
@@ -10,6 +10,8 @@ type Props$1 = {
|
|
|
10
10
|
*/
|
|
11
11
|
name: string;
|
|
12
12
|
urlName?: string;
|
|
13
|
+
isExportable?: boolean;
|
|
14
|
+
isIndexable?: boolean;
|
|
13
15
|
baseURL: string | undefined;
|
|
14
16
|
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
15
17
|
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
@@ -26,7 +28,7 @@ type GetParamsProps$1 = {
|
|
|
26
28
|
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
27
29
|
typeSchemas: OperationSchemas;
|
|
28
30
|
};
|
|
29
|
-
declare function Client({ name, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, paramsCasing, pathParamsType, operation, urlName, }: Props$1): any;
|
|
31
|
+
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, paramsCasing, pathParamsType, operation, urlName, }: Props$1): any;
|
|
30
32
|
declare namespace Client {
|
|
31
33
|
var getParams: ({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps$1) => FunctionParams;
|
|
32
34
|
}
|
package/dist/components.d.ts
CHANGED
|
@@ -10,6 +10,8 @@ type Props$1 = {
|
|
|
10
10
|
*/
|
|
11
11
|
name: string;
|
|
12
12
|
urlName?: string;
|
|
13
|
+
isExportable?: boolean;
|
|
14
|
+
isIndexable?: boolean;
|
|
13
15
|
baseURL: string | undefined;
|
|
14
16
|
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
15
17
|
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
@@ -26,7 +28,7 @@ type GetParamsProps$1 = {
|
|
|
26
28
|
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
27
29
|
typeSchemas: OperationSchemas;
|
|
28
30
|
};
|
|
29
|
-
declare function Client({ name, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, paramsCasing, pathParamsType, operation, urlName, }: Props$1): any;
|
|
31
|
+
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, paramsCasing, pathParamsType, operation, urlName, }: Props$1): any;
|
|
30
32
|
declare namespace Client {
|
|
31
33
|
var getParams: ({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps$1) => FunctionParams;
|
|
32
34
|
}
|
package/dist/components.js
CHANGED
package/dist/generators.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkMR22J6SW_cjs = require('./chunk-MR22J6SW.cjs');
|
|
4
|
+
require('./chunk-LR36WFYS.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "clientGenerator", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkMR22J6SW_cjs.clientGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "groupedClientGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkMR22J6SW_cjs.groupedClientGenerator; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "operationsGenerator", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkMR22J6SW_cjs.operationsGenerator; }
|
|
19
19
|
});
|
|
20
20
|
//# sourceMappingURL=generators.cjs.map
|
|
21
21
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-7B6Q2VE7.js';
|
|
2
|
+
import './chunk-HT47HSI2.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkMR22J6SW_cjs = require('./chunk-MR22J6SW.cjs');
|
|
4
|
+
require('./chunk-LR36WFYS.cjs');
|
|
5
5
|
var path = require('path');
|
|
6
6
|
var core = require('@kubb/core');
|
|
7
7
|
var transformers = require('@kubb/core/transformers');
|
|
@@ -27,7 +27,7 @@ var pluginClient = core.createPlugin((options) => {
|
|
|
27
27
|
operations = false,
|
|
28
28
|
baseURL,
|
|
29
29
|
paramsCasing,
|
|
30
|
-
generators = [
|
|
30
|
+
generators = [chunkMR22J6SW_cjs.clientGenerator, group ? chunkMR22J6SW_cjs.groupedClientGenerator : void 0, operations ? chunkMR22J6SW_cjs.operationsGenerator : void 0].filter(Boolean),
|
|
31
31
|
parser = "client",
|
|
32
32
|
client = "axios",
|
|
33
33
|
importPath = client === "fetch" ? "@kubb/plugin-client/clients/fetch" : "@kubb/plugin-client/clients/axios"
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
import { clientGenerator, groupedClientGenerator, operationsGenerator } from './chunk-7B6Q2VE7.js';
|
|
2
|
+
import './chunk-HT47HSI2.js';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { createPlugin, FileManager, PluginManager } from '@kubb/core';
|
|
5
5
|
import { camelCase } from '@kubb/core/transformers';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "3.5.
|
|
3
|
+
"version": "3.5.5",
|
|
4
4
|
"description": "Generator plugin-client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
},
|
|
71
71
|
"files": [
|
|
72
72
|
"src",
|
|
73
|
+
"clients",
|
|
73
74
|
"dist",
|
|
74
75
|
"client.ts",
|
|
75
76
|
"*.d.ts",
|
|
@@ -78,20 +79,20 @@
|
|
|
78
79
|
"!/**/__tests__/**"
|
|
79
80
|
],
|
|
80
81
|
"dependencies": {
|
|
81
|
-
"@kubb/core": "3.5.
|
|
82
|
-
"@kubb/fs": "3.5.
|
|
83
|
-
"@kubb/oas": "3.5.
|
|
84
|
-
"@kubb/plugin-oas": "3.5.
|
|
85
|
-
"@kubb/plugin-ts": "3.5.
|
|
86
|
-
"@kubb/plugin-zod": "3.5.
|
|
87
|
-
"@kubb/react": "3.5.
|
|
82
|
+
"@kubb/core": "3.5.5",
|
|
83
|
+
"@kubb/fs": "3.5.5",
|
|
84
|
+
"@kubb/oas": "3.5.5",
|
|
85
|
+
"@kubb/plugin-oas": "3.5.5",
|
|
86
|
+
"@kubb/plugin-ts": "3.5.5",
|
|
87
|
+
"@kubb/plugin-zod": "3.5.5",
|
|
88
|
+
"@kubb/react": "3.5.5"
|
|
88
89
|
},
|
|
89
90
|
"devDependencies": {
|
|
90
91
|
"axios": "^1.7.9",
|
|
91
92
|
"tsup": "^8.3.5",
|
|
92
93
|
"typescript": "^5.7.3",
|
|
93
|
-
"@kubb/config-ts": "3.5.
|
|
94
|
-
"@kubb/config-tsup": "3.5.
|
|
94
|
+
"@kubb/config-ts": "3.5.5",
|
|
95
|
+
"@kubb/config-tsup": "3.5.5"
|
|
95
96
|
},
|
|
96
97
|
"peerDependencies": {
|
|
97
98
|
"@kubb/react": "^3.0.0",
|
|
@@ -13,6 +13,9 @@ type Props = {
|
|
|
13
13
|
*/
|
|
14
14
|
name: string
|
|
15
15
|
urlName?: string
|
|
16
|
+
isExportable?: boolean
|
|
17
|
+
isIndexable?: boolean
|
|
18
|
+
|
|
16
19
|
baseURL: string | undefined
|
|
17
20
|
dataReturnType: PluginClient['resolvedOptions']['dataReturnType']
|
|
18
21
|
paramsCasing: PluginClient['resolvedOptions']['paramsCasing']
|
|
@@ -59,7 +62,9 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
|
|
|
59
62
|
},
|
|
60
63
|
},
|
|
61
64
|
config: {
|
|
62
|
-
type: typeSchemas.request?.name
|
|
65
|
+
type: typeSchemas.request?.name
|
|
66
|
+
? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }`
|
|
67
|
+
: 'Partial<RequestConfig> & { client?: typeof client }',
|
|
63
68
|
default: '{}',
|
|
64
69
|
},
|
|
65
70
|
})
|
|
@@ -92,7 +97,9 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
|
|
|
92
97
|
}
|
|
93
98
|
: undefined,
|
|
94
99
|
config: {
|
|
95
|
-
type: typeSchemas.request?.name
|
|
100
|
+
type: typeSchemas.request?.name
|
|
101
|
+
? `Partial<RequestConfig<${typeSchemas.request?.name}>> & { client?: typeof client }`
|
|
102
|
+
: 'Partial<RequestConfig> & { client?: typeof client }',
|
|
96
103
|
default: '{}',
|
|
97
104
|
},
|
|
98
105
|
})
|
|
@@ -100,6 +107,8 @@ function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: Ge
|
|
|
100
107
|
|
|
101
108
|
export function Client({
|
|
102
109
|
name,
|
|
110
|
+
isExportable = true,
|
|
111
|
+
isIndexable = true,
|
|
103
112
|
typeSchemas,
|
|
104
113
|
baseURL,
|
|
105
114
|
dataReturnType,
|
|
@@ -153,10 +162,10 @@ export function Client({
|
|
|
153
162
|
: undefined,
|
|
154
163
|
headers: headers.length
|
|
155
164
|
? {
|
|
156
|
-
value: headers.length ? `{ ${headers.join(', ')}, ...
|
|
165
|
+
value: headers.length ? `{ ${headers.join(', ')}, ...requestConfig.headers }` : undefined,
|
|
157
166
|
}
|
|
158
167
|
: undefined,
|
|
159
|
-
|
|
168
|
+
requestConfig: {
|
|
160
169
|
mode: 'inlineSpread',
|
|
161
170
|
},
|
|
162
171
|
},
|
|
@@ -178,18 +187,21 @@ export function Client({
|
|
|
178
187
|
: ''
|
|
179
188
|
|
|
180
189
|
return (
|
|
181
|
-
<File.Source name={name} isExportable isIndexable>
|
|
190
|
+
<File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>
|
|
182
191
|
<Function
|
|
183
192
|
name={name}
|
|
184
193
|
async
|
|
185
|
-
export
|
|
194
|
+
export={isExportable}
|
|
186
195
|
params={params.toConstructor()}
|
|
187
196
|
JSDoc={{
|
|
188
197
|
comments: getComments(operation),
|
|
189
198
|
}}
|
|
190
199
|
>
|
|
200
|
+
{'const { client:request = client, ...requestConfig } = config'}
|
|
201
|
+
<br />
|
|
202
|
+
<br />
|
|
191
203
|
{formData}
|
|
192
|
-
{`const res = await
|
|
204
|
+
{`const res = await request<${generics.join(', ')}>(${clientParams.toCall()})`}
|
|
193
205
|
<br />
|
|
194
206
|
{dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}
|
|
195
207
|
{dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}
|
|
@@ -11,12 +11,18 @@ export function getDeletePetUrl(petId: DeletePetPathParams['petId']) {
|
|
|
11
11
|
* @summary Deletes a pet
|
|
12
12
|
* {@link /pet/:petId}
|
|
13
13
|
*/
|
|
14
|
-
export async function deletePet(
|
|
15
|
-
|
|
14
|
+
export async function deletePet(
|
|
15
|
+
petId: DeletePetPathParams['petId'],
|
|
16
|
+
headers?: DeletePetHeaderParams,
|
|
17
|
+
config: Partial<RequestConfig> & { client?: typeof client } = {},
|
|
18
|
+
) {
|
|
19
|
+
const { client: request = client, ...requestConfig } = config
|
|
20
|
+
|
|
21
|
+
const res = await request<DeletePetMutationResponse, ResponseErrorConfig<DeletePet400>, unknown>({
|
|
16
22
|
method: 'DELETE',
|
|
17
23
|
url: getDeletePetUrl(petId).toString(),
|
|
18
|
-
headers: { ...headers, ...
|
|
19
|
-
...
|
|
24
|
+
headers: { ...headers, ...requestConfig.headers },
|
|
25
|
+
...requestConfig,
|
|
20
26
|
})
|
|
21
27
|
return res.data
|
|
22
28
|
}
|
|
@@ -11,12 +11,18 @@ export function getDeletePetUrl({ petId }: { petId: DeletePetPathParams['petId']
|
|
|
11
11
|
* @summary Deletes a pet
|
|
12
12
|
* {@link /pet/:petId}
|
|
13
13
|
*/
|
|
14
|
-
export async function deletePet(
|
|
15
|
-
|
|
14
|
+
export async function deletePet(
|
|
15
|
+
{ petId }: { petId: DeletePetPathParams['petId'] },
|
|
16
|
+
headers?: DeletePetHeaderParams,
|
|
17
|
+
config: Partial<RequestConfig> & { client?: typeof client } = {},
|
|
18
|
+
) {
|
|
19
|
+
const { client: request = client, ...requestConfig } = config
|
|
20
|
+
|
|
21
|
+
const res = await request<DeletePetMutationResponse, ResponseErrorConfig<DeletePet400>, unknown>({
|
|
16
22
|
method: 'DELETE',
|
|
17
23
|
url: getDeletePetUrl({ petId }).toString(),
|
|
18
|
-
headers: { ...headers, ...
|
|
19
|
-
...
|
|
24
|
+
headers: { ...headers, ...requestConfig.headers },
|
|
25
|
+
...requestConfig,
|
|
20
26
|
})
|
|
21
27
|
return res.data
|
|
22
28
|
}
|
|
@@ -11,12 +11,14 @@ export function getFindPetsByTagsUrl() {
|
|
|
11
11
|
* @summary Finds Pets by tags
|
|
12
12
|
* {@link /pet/findByTags}
|
|
13
13
|
*/
|
|
14
|
-
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
15
|
-
const
|
|
14
|
+
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> & { client?: typeof client } = {}) {
|
|
15
|
+
const { client: request = client, ...requestConfig } = config
|
|
16
|
+
|
|
17
|
+
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
16
18
|
method: 'GET',
|
|
17
19
|
url: getFindPetsByTagsUrl().toString(),
|
|
18
20
|
params,
|
|
19
|
-
...
|
|
21
|
+
...requestConfig,
|
|
20
22
|
})
|
|
21
23
|
return res.data
|
|
22
24
|
}
|
|
@@ -11,12 +11,14 @@ export function getFindPetsByTagsUrl() {
|
|
|
11
11
|
* @summary Finds Pets by tags
|
|
12
12
|
* {@link /pet/findByTags}
|
|
13
13
|
*/
|
|
14
|
-
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
15
|
-
const
|
|
14
|
+
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> & { client?: typeof client } = {}) {
|
|
15
|
+
const { client: request = client, ...requestConfig } = config
|
|
16
|
+
|
|
17
|
+
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
16
18
|
method: 'GET',
|
|
17
19
|
url: getFindPetsByTagsUrl().toString(),
|
|
18
20
|
params,
|
|
19
|
-
...
|
|
21
|
+
...requestConfig,
|
|
20
22
|
})
|
|
21
23
|
return res
|
|
22
24
|
}
|
|
@@ -11,12 +11,14 @@ export function getFindPetsByTagsUrl() {
|
|
|
11
11
|
* @summary Finds Pets by tags
|
|
12
12
|
* {@link /pet/findByTags}
|
|
13
13
|
*/
|
|
14
|
-
export async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
|
|
15
|
-
const
|
|
14
|
+
export async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> & { client?: typeof client } = {}) {
|
|
15
|
+
const { client: request = client, ...requestConfig } = config
|
|
16
|
+
|
|
17
|
+
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
16
18
|
method: 'GET',
|
|
17
19
|
url: getFindPetsByTagsUrl().toString(),
|
|
18
20
|
params,
|
|
19
|
-
...
|
|
21
|
+
...requestConfig,
|
|
20
22
|
})
|
|
21
23
|
return res.data
|
|
22
24
|
}
|
|
@@ -11,12 +11,14 @@ export function getFindPetsByTagsUrl() {
|
|
|
11
11
|
* @summary Finds Pets by tags
|
|
12
12
|
* {@link /pet/findByTags}
|
|
13
13
|
*/
|
|
14
|
-
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
15
|
-
const
|
|
14
|
+
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> & { client?: typeof client } = {}) {
|
|
15
|
+
const { client: request = client, ...requestConfig } = config
|
|
16
|
+
|
|
17
|
+
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
16
18
|
method: 'GET',
|
|
17
19
|
url: getFindPetsByTagsUrl().toString(),
|
|
18
20
|
params,
|
|
19
|
-
...
|
|
21
|
+
...requestConfig,
|
|
20
22
|
})
|
|
21
23
|
return findPetsByTagsQueryResponse.parse(res.data)
|
|
22
24
|
}
|
|
@@ -11,12 +11,14 @@ export function getFindPetsByTagsUrl() {
|
|
|
11
11
|
* @summary Finds Pets by tags
|
|
12
12
|
* {@link /pet/findByTags}
|
|
13
13
|
*/
|
|
14
|
-
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
15
|
-
const
|
|
14
|
+
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> & { client?: typeof client } = {}) {
|
|
15
|
+
const { client: request = client, ...requestConfig } = config
|
|
16
|
+
|
|
17
|
+
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
16
18
|
method: 'GET',
|
|
17
19
|
url: getFindPetsByTagsUrl().toString(),
|
|
18
20
|
params,
|
|
19
|
-
...
|
|
21
|
+
...requestConfig,
|
|
20
22
|
})
|
|
21
23
|
return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) }
|
|
22
24
|
}
|
|
@@ -11,12 +11,14 @@ export function getFindPetsByTagsUrl() {
|
|
|
11
11
|
* @summary Finds Pets by tags
|
|
12
12
|
* {@link /pet/findByTags}
|
|
13
13
|
*/
|
|
14
|
-
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
15
|
-
const
|
|
14
|
+
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> & { client?: typeof client } = {}) {
|
|
15
|
+
const { client: request = client, ...requestConfig } = config
|
|
16
|
+
|
|
17
|
+
const res = await request<FindPetsByTagsQueryResponse, ResponseErrorConfig<FindPetsByTags400>, unknown>({
|
|
16
18
|
method: 'GET',
|
|
17
19
|
url: getFindPetsByTagsUrl().toString(),
|
|
18
20
|
params,
|
|
19
|
-
...
|
|
21
|
+
...requestConfig,
|
|
20
22
|
})
|
|
21
23
|
return res.data
|
|
22
24
|
}
|
|
@@ -13,13 +13,15 @@ export function getUpdatePetWithFormUrl(petId: UpdatePetWithFormPathParams['petI
|
|
|
13
13
|
export async function updatePetWithForm(
|
|
14
14
|
petId: UpdatePetWithFormPathParams['petId'],
|
|
15
15
|
params?: UpdatePetWithFormQueryParams,
|
|
16
|
-
config: Partial<RequestConfig> = {},
|
|
16
|
+
config: Partial<RequestConfig> & { client?: typeof client } = {},
|
|
17
17
|
) {
|
|
18
|
-
const
|
|
18
|
+
const { client: request = client, ...requestConfig } = config
|
|
19
|
+
|
|
20
|
+
const res = await request<UpdatePetWithFormMutationResponse, ResponseErrorConfig<UpdatePetWithForm405>, unknown>({
|
|
19
21
|
method: 'POST',
|
|
20
22
|
url: getUpdatePetWithFormUrl(petId).toString(),
|
|
21
23
|
params,
|
|
22
|
-
...
|
|
24
|
+
...requestConfig,
|
|
23
25
|
})
|
|
24
26
|
return res.data
|
|
25
27
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Url.tsx","../src/components/Client.tsx","../src/components/Operations.tsx"],"names":["FunctionParams","getPathParams","isOptional","URLPath","jsx","File","Function","getParams","jsxs","getComments","Const"],"mappings":";;;;;;;;;AA+BA,SAAS,UAAU,EAAE,UAAA,EAAY,YAAc,EAAA,cAAA,EAAgB,aAA+B,EAAA;AAC5F,EAAA,IAAI,eAAe,QAAU,EAAA;AAC3B,IAAA,OAAOA,qBAAe,OAAQ,CAAA;AAAA,MAC5B,IAAM,EAAA;AAAA,QACJ,IAAM,EAAA,QAAA;AAAA,QACN,QAAU,EAAA;AAAA,UACR,GAAGC,sBAAc,WAAY,CAAA,UAAA,EAAY,EAAE,KAAO,EAAA,IAAA,EAAM,MAAQ,EAAA,YAAA,EAAc;AAAA;AAChF;AACF,KACD,CAAA;AAAA;AAGH,EAAA,OAAOD,qBAAe,OAAQ,CAAA;AAAA,IAC5B,UAAA,EAAY,WAAY,CAAA,UAAA,EAAY,IAChC,GAAA;AAAA,MACE,IAAA,EAAM,cAAmB,KAAA,QAAA,GAAW,QAAW,GAAA,cAAA;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AAA,EAChD,CACF,EAAA,CAAA;AAEJ","file":"chunk-36TRCKLD.cjs","sourcesContent":["import { URLPath } from '@kubb/core/utils'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { PluginClient } from '../types.ts'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n isExportable?: boolean\n isIndexable?: boolean\n\n baseURL: string | undefined\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['pathParamsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['paramsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n },\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n })\n}\n\nexport function Url({ name, isExportable = true, isIndexable = true, typeSchemas, baseURL, paramsType, paramsCasing, pathParamsType, operation }: Props) {\n const path = new URLPath(operation.path, { casing: paramsCasing })\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n\n return (\n <File.Source name={name} isExportable={isExportable} isIndexable={isIndexable}>\n <Function name={name} export={isExportable} params={params.toConstructor()}>\n {`return ${path.toTemplateString({ prefix: baseURL })} as const`}\n </Function>\n </File.Source>\n )\n}\n\nUrl.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\n\nimport { type Operation, isOptional } from '@kubb/oas'\nimport type { OperationSchemas } from '@kubb/plugin-oas'\nimport { getComments, getPathParams } from '@kubb/plugin-oas/utils'\nimport { File, Function, FunctionParams } from '@kubb/react'\nimport type { PluginClient } from '../types.ts'\nimport { Url } from './Url.tsx'\n\ntype Props = {\n /**\n * Name of the function\n */\n name: string\n urlName?: string\n baseURL: string | undefined\n dataReturnType: PluginClient['resolvedOptions']['dataReturnType']\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['pathParamsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n parser: PluginClient['resolvedOptions']['parser'] | undefined\n typeSchemas: OperationSchemas\n zodSchemas: OperationSchemas | undefined\n operation: Operation\n}\n\ntype GetParamsProps = {\n paramsCasing: PluginClient['resolvedOptions']['paramsCasing']\n paramsType: PluginClient['resolvedOptions']['paramsType']\n pathParamsType: PluginClient['resolvedOptions']['pathParamsType']\n typeSchemas: OperationSchemas\n}\n\nfunction getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {\n if (paramsType === 'object') {\n return FunctionParams.factory({\n data: {\n mode: 'object',\n children: {\n ...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n },\n },\n config: {\n type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',\n default: '{}',\n },\n })\n }\n\n return FunctionParams.factory({\n pathParams: typeSchemas.pathParams?.name\n ? {\n mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',\n children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),\n optional: isOptional(typeSchemas.pathParams?.schema),\n }\n : undefined,\n data: typeSchemas.request?.name\n ? {\n type: typeSchemas.request?.name,\n optional: isOptional(typeSchemas.request?.schema),\n }\n : undefined,\n params: typeSchemas.queryParams?.name\n ? {\n type: typeSchemas.queryParams?.name,\n optional: isOptional(typeSchemas.queryParams?.schema),\n }\n : undefined,\n headers: typeSchemas.headerParams?.name\n ? {\n type: typeSchemas.headerParams?.name,\n optional: isOptional(typeSchemas.headerParams?.schema),\n }\n : undefined,\n config: {\n type: typeSchemas.request?.name ? `Partial<RequestConfig<${typeSchemas.request?.name}>>` : 'Partial<RequestConfig>',\n default: '{}',\n },\n })\n}\n\nexport function Client({\n name,\n typeSchemas,\n baseURL,\n dataReturnType,\n parser,\n zodSchemas,\n paramsType,\n paramsCasing,\n pathParamsType,\n operation,\n urlName,\n}: Props) {\n const path = new URLPath(operation.path, { casing: paramsCasing })\n const contentType = operation.getContentType()\n const isFormData = contentType === 'multipart/form-data'\n const headers = [\n contentType !== 'application/json' ? `'Content-Type': '${contentType}'` : undefined,\n typeSchemas.headerParams?.name ? '...headers' : undefined,\n ].filter(Boolean)\n\n const TError = `ResponseErrorConfig<${typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error'}>`\n\n const generics = [typeSchemas.response.name, TError, typeSchemas.request?.name || 'unknown'].filter(Boolean)\n const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })\n const urlParams = Url.getParams({\n paramsType,\n paramsCasing,\n pathParamsType,\n typeSchemas,\n })\n const clientParams = FunctionParams.factory({\n config: {\n mode: 'object',\n children: {\n method: {\n value: JSON.stringify(operation.method.toUpperCase()),\n },\n url: {\n value: urlName ? `${urlName}(${urlParams.toCall()}).toString()` : path.template,\n },\n baseURL:\n baseURL && !urlName\n ? {\n value: JSON.stringify(baseURL),\n }\n : undefined,\n params: typeSchemas.queryParams?.name ? {} : undefined,\n data: typeSchemas.request?.name\n ? {\n value: isFormData ? 'formData' : undefined,\n }\n : undefined,\n headers: headers.length\n ? {\n value: headers.length ? `{ ${headers.join(', ')}, ...config.headers }` : undefined,\n }\n : undefined,\n config: {\n mode: 'inlineSpread',\n },\n },\n },\n })\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key as keyof typeof data];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : ''\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Function\n name={name}\n async\n export\n params={params.toConstructor()}\n JSDoc={{\n comments: getComments(operation),\n }}\n >\n {formData}\n {`const res = await client<${generics.join(', ')}>(${clientParams.toCall()})`}\n <br />\n {dataReturnType === 'full' && parser === 'zod' && zodSchemas && `return {...res, data: ${zodSchemas.response.name}.parse(res.data)}`}\n {dataReturnType === 'data' && parser === 'zod' && zodSchemas && `return ${zodSchemas.response.name}.parse(res.data)`}\n {dataReturnType === 'full' && parser === 'client' && 'return res'}\n {dataReturnType === 'data' && parser === 'client' && 'return res.data'}\n </Function>\n </File.Source>\n )\n}\n\nClient.getParams = getParams\n","import { URLPath } from '@kubb/core/utils'\nimport { Const, File } from '@kubb/react'\n\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype OperationsProps = {\n name: string\n operations: Array<Operation>\n}\n\nexport function Operations({ name, operations }: OperationsProps) {\n const operationsObject: Record<string, { path: string; method: HttpMethod }> = {}\n\n operations.forEach((operation) => {\n operationsObject[operation.getOperationId()] = {\n path: new URLPath(operation.path).URL,\n method: operation.method,\n }\n })\n\n return (\n <File.Source name={name} isExportable isIndexable>\n <Const name={name} export asConst>\n {JSON.stringify(operationsObject, undefined, 2)}\n </Const>\n </File.Source>\n )\n}\n"]}
|