@kubb/plugin-client 3.1.0 → 3.3.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.
- package/dist/{chunk-AQLX7AYH.js → chunk-3WVVUCEB.js} +8 -7
- package/dist/chunk-3WVVUCEB.js.map +1 -0
- package/dist/{chunk-Q5RLJCQK.cjs → chunk-4OXWRJFQ.cjs} +8 -7
- package/dist/chunk-4OXWRJFQ.cjs.map +1 -0
- package/dist/{chunk-QZNPGI7U.cjs → chunk-TX2PSIPH.cjs} +11 -7
- package/dist/chunk-TX2PSIPH.cjs.map +1 -0
- package/dist/{chunk-IES3MXTP.js → chunk-UIFBYWMG.js} +9 -5
- package/dist/chunk-UIFBYWMG.js.map +1 -0
- package/dist/{client.cjs → clients/axios.cjs} +5 -5
- package/dist/clients/axios.cjs.map +1 -0
- package/dist/{client.js → clients/axios.js} +5 -5
- package/dist/clients/axios.js.map +1 -0
- package/dist/clients/fetch.cjs +31 -0
- package/dist/clients/fetch.cjs.map +1 -0
- package/dist/clients/fetch.d.cts +29 -0
- package/dist/clients/fetch.d.ts +29 -0
- package/dist/clients/fetch.js +26 -0
- package/dist/clients/fetch.js.map +1 -0
- package/dist/components.cjs +3 -3
- package/dist/components.d.cts +5 -3
- package/dist/components.d.ts +5 -3
- package/dist/components.js +1 -1
- package/dist/generators.cjs +5 -5
- package/dist/generators.d.cts +1 -1
- package/dist/generators.d.ts +1 -1
- package/dist/generators.js +2 -2
- package/dist/index.cjs +4 -4
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -2
- package/dist/{types-DXab6SYO.d.cts → types-P398e_Yv.d.cts} +15 -2
- package/dist/{types-DXab6SYO.d.ts → types-P398e_Yv.d.ts} +15 -2
- package/package.json +24 -18
- package/src/clients/fetch.ts +48 -0
- package/src/components/Client.tsx +8 -5
- package/src/generators/__snapshots__/deletePet.ts +11 -6
- package/src/generators/__snapshots__/deletePetObject.ts +11 -8
- package/src/generators/__snapshots__/findByTags.ts +5 -5
- package/src/generators/__snapshots__/findByTagsFull.ts +5 -5
- package/src/generators/__snapshots__/findByTagsObject.ts +6 -8
- package/src/generators/__snapshots__/findByTagsWithZod.ts +5 -5
- package/src/generators/__snapshots__/findByTagsWithZodFull.ts +5 -5
- package/src/generators/__snapshots__/importPath.ts +5 -5
- package/src/generators/__snapshots__/operations.ts +81 -81
- package/src/generators/__snapshots__/updatePetById.ts +10 -6
- package/src/generators/clientGenerator.tsx +1 -0
- package/src/plugin.ts +4 -1
- package/src/types.ts +15 -2
- package/dist/chunk-AQLX7AYH.js.map +0 -1
- package/dist/chunk-IES3MXTP.js.map +0 -1
- package/dist/chunk-Q5RLJCQK.cjs.map +0 -1
- package/dist/chunk-QZNPGI7U.cjs.map +0 -1
- package/dist/client.cjs.map +0 -1
- package/dist/client.js.map +0 -1
- /package/dist/{client.d.cts → clients/axios.d.cts} +0 -0
- /package/dist/{client.d.ts → clients/axios.d.ts} +0 -0
- /package/{client.ts → src/clients/axios.ts} +0 -0
package/dist/components.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { Operation } from '@kubb/oas';
|
|
|
2
2
|
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
3
|
import { FunctionParams } from '@kubb/react';
|
|
4
4
|
import { KubbNode } from '@kubb/react/types';
|
|
5
|
-
import { P as PluginClient } from './types-
|
|
5
|
+
import { P as PluginClient } from './types-P398e_Yv.cjs';
|
|
6
6
|
import '@kubb/core';
|
|
7
7
|
|
|
8
8
|
type Props = {
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
isIndexable?: boolean;
|
|
15
15
|
baseURL: string | undefined;
|
|
16
16
|
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
17
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
17
18
|
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
18
19
|
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
19
20
|
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
@@ -22,13 +23,14 @@ type Props = {
|
|
|
22
23
|
operation: Operation;
|
|
23
24
|
};
|
|
24
25
|
type GetParamsProps = {
|
|
26
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
25
27
|
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
26
28
|
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
27
29
|
typeSchemas: OperationSchemas;
|
|
28
30
|
};
|
|
29
|
-
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, pathParamsType, operation, }: Props): KubbNode;
|
|
31
|
+
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, paramsCasing, pathParamsType, operation, }: Props): KubbNode;
|
|
30
32
|
declare namespace Client {
|
|
31
|
-
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
33
|
+
var getParams: ({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
type OperationsProps = {
|
package/dist/components.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Operation } from '@kubb/oas';
|
|
|
2
2
|
import { OperationSchemas } from '@kubb/plugin-oas';
|
|
3
3
|
import { FunctionParams } from '@kubb/react';
|
|
4
4
|
import { KubbNode } from '@kubb/react/types';
|
|
5
|
-
import { P as PluginClient } from './types-
|
|
5
|
+
import { P as PluginClient } from './types-P398e_Yv.js';
|
|
6
6
|
import '@kubb/core';
|
|
7
7
|
|
|
8
8
|
type Props = {
|
|
@@ -14,6 +14,7 @@ type Props = {
|
|
|
14
14
|
isIndexable?: boolean;
|
|
15
15
|
baseURL: string | undefined;
|
|
16
16
|
dataReturnType: PluginClient['resolvedOptions']['dataReturnType'];
|
|
17
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
17
18
|
paramsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
18
19
|
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
19
20
|
parser: PluginClient['resolvedOptions']['parser'] | undefined;
|
|
@@ -22,13 +23,14 @@ type Props = {
|
|
|
22
23
|
operation: Operation;
|
|
23
24
|
};
|
|
24
25
|
type GetParamsProps = {
|
|
26
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing'];
|
|
25
27
|
paramsType: PluginClient['resolvedOptions']['paramsType'];
|
|
26
28
|
pathParamsType: PluginClient['resolvedOptions']['pathParamsType'];
|
|
27
29
|
typeSchemas: OperationSchemas;
|
|
28
30
|
};
|
|
29
|
-
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, pathParamsType, operation, }: Props): KubbNode;
|
|
31
|
+
declare function Client({ name, isExportable, isIndexable, typeSchemas, baseURL, dataReturnType, parser, zodSchemas, paramsType, paramsCasing, pathParamsType, operation, }: Props): KubbNode;
|
|
30
32
|
declare namespace Client {
|
|
31
|
-
var getParams: ({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
33
|
+
var getParams: ({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) => FunctionParams;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
type OperationsProps = {
|
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 chunkTX2PSIPH_cjs = require('./chunk-TX2PSIPH.cjs');
|
|
4
|
+
require('./chunk-4OXWRJFQ.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 chunkTX2PSIPH_cjs.clientGenerator; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "groupedClientGenerator", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkTX2PSIPH_cjs.groupedClientGenerator; }
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "operationsGenerator", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkTX2PSIPH_cjs.operationsGenerator; }
|
|
19
19
|
});
|
|
20
20
|
//# sourceMappingURL=generators.cjs.map
|
|
21
21
|
//# sourceMappingURL=generators.cjs.map
|
package/dist/generators.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
-
import { P as PluginClient } from './types-
|
|
2
|
+
import { P as PluginClient } from './types-P398e_Yv.cjs';
|
|
3
3
|
import '@kubb/core';
|
|
4
4
|
|
|
5
5
|
declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
package/dist/generators.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _kubb_plugin_oas from '@kubb/plugin-oas';
|
|
2
|
-
import { P as PluginClient } from './types-
|
|
2
|
+
import { P as PluginClient } from './types-P398e_Yv.js';
|
|
3
3
|
import '@kubb/core';
|
|
4
4
|
|
|
5
5
|
declare const clientGenerator: _kubb_plugin_oas.Generator<PluginClient>;
|
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-UIFBYWMG.js';
|
|
2
|
+
import './chunk-3WVVUCEB.js';
|
|
3
3
|
//# sourceMappingURL=generators.js.map
|
|
4
4
|
//# sourceMappingURL=generators.js.map
|
package/dist/index.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
3
|
+
var chunkTX2PSIPH_cjs = require('./chunk-TX2PSIPH.cjs');
|
|
4
|
+
require('./chunk-4OXWRJFQ.cjs');
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
Object.defineProperty(exports, "pluginClient", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function () { return
|
|
10
|
+
get: function () { return chunkTX2PSIPH_cjs.pluginClient; }
|
|
11
11
|
});
|
|
12
12
|
Object.defineProperty(exports, "pluginClientName", {
|
|
13
13
|
enumerable: true,
|
|
14
|
-
get: function () { return
|
|
14
|
+
get: function () { return chunkTX2PSIPH_cjs.pluginClientName; }
|
|
15
15
|
});
|
|
16
16
|
//# sourceMappingURL=index.cjs.map
|
|
17
17
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginClient } from './types-
|
|
2
|
+
import { O as Options, P as PluginClient } from './types-P398e_Yv.cjs';
|
|
3
3
|
import '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
declare const pluginClientName = "plugin-client";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _kubb_core from '@kubb/core';
|
|
2
|
-
import { O as Options, P as PluginClient } from './types-
|
|
2
|
+
import { O as Options, P as PluginClient } from './types-P398e_Yv.js';
|
|
3
3
|
import '@kubb/plugin-oas';
|
|
4
4
|
|
|
5
5
|
declare const pluginClientName = "plugin-client";
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { pluginClient, pluginClientName } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { pluginClient, pluginClientName } from './chunk-UIFBYWMG.js';
|
|
2
|
+
import './chunk-3WVVUCEB.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -32,7 +32,7 @@ type Options = {
|
|
|
32
32
|
* Path to the client import path that will be used to do the API calls.
|
|
33
33
|
* It will be used as `import client from '${client.importPath}'`.
|
|
34
34
|
* It allows both relative and absolute path but be aware that we will not change the path.
|
|
35
|
-
* @default '@kubb/plugin-client/
|
|
35
|
+
* @default '@kubb/plugin-client/clients/axios'
|
|
36
36
|
*/
|
|
37
37
|
importPath?: string;
|
|
38
38
|
/**
|
|
@@ -46,6 +46,11 @@ type Options = {
|
|
|
46
46
|
* @default 'data'
|
|
47
47
|
*/
|
|
48
48
|
dataReturnType?: 'data' | 'full';
|
|
49
|
+
/**
|
|
50
|
+
* How to style your params, by default no casing is applied
|
|
51
|
+
* - 'camelcase' will use camelcase for the params names
|
|
52
|
+
*/
|
|
53
|
+
paramsCasing?: 'camelcase';
|
|
49
54
|
/**
|
|
50
55
|
* How to pass your params
|
|
51
56
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -62,10 +67,17 @@ type Options = {
|
|
|
62
67
|
pathParamsType?: 'object' | 'inline';
|
|
63
68
|
/**
|
|
64
69
|
* Which parser can be used before returning the data
|
|
65
|
-
* - 'zod'
|
|
70
|
+
* - 'zod' will use `@kubb/plugin-zod` to parse the data.
|
|
66
71
|
* @default 'client'
|
|
67
72
|
*/
|
|
68
73
|
parser?: 'client' | 'zod';
|
|
74
|
+
/**
|
|
75
|
+
* Which client should be used to do the HTTP calls
|
|
76
|
+
* - 'axios' will use `@kubb/plugin-client/clients/axios` to fetch data.
|
|
77
|
+
* - 'fetch' will use `@kubb/plugin-client/clients/fetch` to fetch data.
|
|
78
|
+
* @default 'axios'
|
|
79
|
+
*/
|
|
80
|
+
client?: 'axios' | 'fetch';
|
|
69
81
|
transformers?: {
|
|
70
82
|
/**
|
|
71
83
|
* Customize the names based on the type that is provided by the plugin.
|
|
@@ -86,6 +98,7 @@ type ResolvedOptions = {
|
|
|
86
98
|
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
87
99
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
88
100
|
paramsType: NonNullable<Options['paramsType']>;
|
|
101
|
+
paramsCasing: Options['paramsCasing'];
|
|
89
102
|
};
|
|
90
103
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
91
104
|
|
|
@@ -32,7 +32,7 @@ type Options = {
|
|
|
32
32
|
* Path to the client import path that will be used to do the API calls.
|
|
33
33
|
* It will be used as `import client from '${client.importPath}'`.
|
|
34
34
|
* It allows both relative and absolute path but be aware that we will not change the path.
|
|
35
|
-
* @default '@kubb/plugin-client/
|
|
35
|
+
* @default '@kubb/plugin-client/clients/axios'
|
|
36
36
|
*/
|
|
37
37
|
importPath?: string;
|
|
38
38
|
/**
|
|
@@ -46,6 +46,11 @@ type Options = {
|
|
|
46
46
|
* @default 'data'
|
|
47
47
|
*/
|
|
48
48
|
dataReturnType?: 'data' | 'full';
|
|
49
|
+
/**
|
|
50
|
+
* How to style your params, by default no casing is applied
|
|
51
|
+
* - 'camelcase' will use camelcase for the params names
|
|
52
|
+
*/
|
|
53
|
+
paramsCasing?: 'camelcase';
|
|
49
54
|
/**
|
|
50
55
|
* How to pass your params
|
|
51
56
|
* - 'object' will return the params and pathParams as an object.
|
|
@@ -62,10 +67,17 @@ type Options = {
|
|
|
62
67
|
pathParamsType?: 'object' | 'inline';
|
|
63
68
|
/**
|
|
64
69
|
* Which parser can be used before returning the data
|
|
65
|
-
* - 'zod'
|
|
70
|
+
* - 'zod' will use `@kubb/plugin-zod` to parse the data.
|
|
66
71
|
* @default 'client'
|
|
67
72
|
*/
|
|
68
73
|
parser?: 'client' | 'zod';
|
|
74
|
+
/**
|
|
75
|
+
* Which client should be used to do the HTTP calls
|
|
76
|
+
* - 'axios' will use `@kubb/plugin-client/clients/axios` to fetch data.
|
|
77
|
+
* - 'fetch' will use `@kubb/plugin-client/clients/fetch` to fetch data.
|
|
78
|
+
* @default 'axios'
|
|
79
|
+
*/
|
|
80
|
+
client?: 'axios' | 'fetch';
|
|
69
81
|
transformers?: {
|
|
70
82
|
/**
|
|
71
83
|
* Customize the names based on the type that is provided by the plugin.
|
|
@@ -86,6 +98,7 @@ type ResolvedOptions = {
|
|
|
86
98
|
dataReturnType: NonNullable<Options['dataReturnType']>;
|
|
87
99
|
pathParamsType: NonNullable<Options['pathParamsType']>;
|
|
88
100
|
paramsType: NonNullable<Options['paramsType']>;
|
|
101
|
+
paramsCasing: Options['paramsCasing'];
|
|
89
102
|
};
|
|
90
103
|
type PluginClient = PluginFactoryOptions<'plugin-client', Options, ResolvedOptions, never, ResolvePathOptions>;
|
|
91
104
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-client",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Generator plugin-client",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
"require": "./dist/components.cjs",
|
|
37
37
|
"default": "./dist/components.cjs"
|
|
38
38
|
},
|
|
39
|
-
"./
|
|
40
|
-
"import": "./dist/
|
|
41
|
-
"require": "./dist/
|
|
42
|
-
"default": "./dist/
|
|
39
|
+
"./clients/axios": {
|
|
40
|
+
"import": "./dist/clients/axios.js",
|
|
41
|
+
"require": "./dist/clients/axios.cjs",
|
|
42
|
+
"default": "./dist/clients/axios.cjs"
|
|
43
43
|
},
|
|
44
|
-
"./
|
|
45
|
-
"import": "./
|
|
46
|
-
"require": "./
|
|
47
|
-
"default": "./
|
|
44
|
+
"./clients/fetch": {
|
|
45
|
+
"import": "./dist/clients/fetch.js",
|
|
46
|
+
"require": "./dist/clients/fetch.cjs",
|
|
47
|
+
"default": "./dist/clients/fetch.cjs"
|
|
48
48
|
},
|
|
49
49
|
"./package.json": "./package.json",
|
|
50
50
|
"./*": "./*"
|
|
@@ -59,6 +59,12 @@
|
|
|
59
59
|
],
|
|
60
60
|
"generators": [
|
|
61
61
|
"./dist/generators.d.ts"
|
|
62
|
+
],
|
|
63
|
+
"clients/axios": [
|
|
64
|
+
"./dist/clients/axios.d.ts"
|
|
65
|
+
],
|
|
66
|
+
"clients/fetch": [
|
|
67
|
+
"./dist/clients/fetch.d.ts"
|
|
62
68
|
]
|
|
63
69
|
}
|
|
64
70
|
},
|
|
@@ -72,20 +78,20 @@
|
|
|
72
78
|
"!/**/__tests__/**"
|
|
73
79
|
],
|
|
74
80
|
"dependencies": {
|
|
75
|
-
"@kubb/core": "3.
|
|
76
|
-
"@kubb/fs": "3.
|
|
77
|
-
"@kubb/oas": "3.
|
|
78
|
-
"@kubb/plugin-oas": "3.
|
|
79
|
-
"@kubb/plugin-ts": "3.
|
|
80
|
-
"@kubb/plugin-zod": "3.
|
|
81
|
-
"@kubb/react": "3.
|
|
81
|
+
"@kubb/core": "3.3.0",
|
|
82
|
+
"@kubb/fs": "3.3.0",
|
|
83
|
+
"@kubb/oas": "3.3.0",
|
|
84
|
+
"@kubb/plugin-oas": "3.3.0",
|
|
85
|
+
"@kubb/plugin-ts": "3.3.0",
|
|
86
|
+
"@kubb/plugin-zod": "3.3.0",
|
|
87
|
+
"@kubb/react": "3.3.0"
|
|
82
88
|
},
|
|
83
89
|
"devDependencies": {
|
|
84
90
|
"axios": "^1.7.9",
|
|
85
91
|
"tsup": "^8.3.5",
|
|
86
92
|
"typescript": "^5.7.2",
|
|
87
|
-
"@kubb/config-ts": "3.
|
|
88
|
-
"@kubb/config-tsup": "3.
|
|
93
|
+
"@kubb/config-ts": "3.3.0",
|
|
94
|
+
"@kubb/config-tsup": "3.3.0"
|
|
89
95
|
},
|
|
90
96
|
"peerDependencies": {
|
|
91
97
|
"@kubb/react": "^3.0.0",
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subset of AxiosRequestConfig
|
|
3
|
+
*/
|
|
4
|
+
export type RequestConfig<TData = unknown> = {
|
|
5
|
+
baseURL?: string
|
|
6
|
+
url?: string
|
|
7
|
+
method: 'GET' | 'PUT' | 'PATCH' | 'POST' | 'DELETE' | 'OPTIONS'
|
|
8
|
+
params?: unknown
|
|
9
|
+
data?: TData | FormData
|
|
10
|
+
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream'
|
|
11
|
+
signal?: AbortSignal
|
|
12
|
+
headers?: [string, string][] | Record<string, string>
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Subset of AxiosResponse
|
|
16
|
+
*/
|
|
17
|
+
export type ResponseConfig<TData = unknown> = {
|
|
18
|
+
data: TData
|
|
19
|
+
status: number
|
|
20
|
+
statusText: string
|
|
21
|
+
headers?: [string, string][] | Record<string, string>
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const fetchClient = async <TData, TError = unknown, TVariables = unknown>(config: RequestConfig<TVariables>): Promise<ResponseConfig<TData>> => {
|
|
25
|
+
const response = await fetch('https://example.org/post', {
|
|
26
|
+
method: config.method.toUpperCase(),
|
|
27
|
+
body: JSON.stringify(config.data),
|
|
28
|
+
signal: config.signal,
|
|
29
|
+
headers: config.headers,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const data = (await response.json()) as TData
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
data,
|
|
36
|
+
status: response.status,
|
|
37
|
+
statusText: response.statusText,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
fetchClient.getConfig = () => {
|
|
42
|
+
throw new Error('Not supported')
|
|
43
|
+
}
|
|
44
|
+
fetchClient.setConfig = () => {
|
|
45
|
+
throw new Error('Not supported')
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default fetchClient
|
|
@@ -17,6 +17,7 @@ type Props = {
|
|
|
17
17
|
|
|
18
18
|
baseURL: string | undefined
|
|
19
19
|
dataReturnType: PluginClient['resolvedOptions']['dataReturnType']
|
|
20
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing']
|
|
20
21
|
paramsType: PluginClient['resolvedOptions']['pathParamsType']
|
|
21
22
|
pathParamsType: PluginClient['resolvedOptions']['pathParamsType']
|
|
22
23
|
parser: PluginClient['resolvedOptions']['parser'] | undefined
|
|
@@ -26,18 +27,19 @@ type Props = {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
type GetParamsProps = {
|
|
30
|
+
paramsCasing: PluginClient['resolvedOptions']['paramsCasing']
|
|
29
31
|
paramsType: PluginClient['resolvedOptions']['paramsType']
|
|
30
32
|
pathParamsType: PluginClient['resolvedOptions']['pathParamsType']
|
|
31
33
|
typeSchemas: OperationSchemas
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
36
|
+
function getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas }: GetParamsProps) {
|
|
35
37
|
if (paramsType === 'object') {
|
|
36
38
|
return FunctionParams.factory({
|
|
37
39
|
data: {
|
|
38
40
|
mode: 'object',
|
|
39
41
|
children: {
|
|
40
|
-
...getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
42
|
+
...getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
41
43
|
data: typeSchemas.request?.name
|
|
42
44
|
? {
|
|
43
45
|
type: typeSchemas.request?.name,
|
|
@@ -69,7 +71,7 @@ function getParams({ paramsType, pathParamsType, typeSchemas }: GetParamsProps)
|
|
|
69
71
|
pathParams: typeSchemas.pathParams?.name
|
|
70
72
|
? {
|
|
71
73
|
mode: pathParamsType === 'object' ? 'object' : 'inlineSpread',
|
|
72
|
-
children: getPathParams(typeSchemas.pathParams, { typed: true }),
|
|
74
|
+
children: getPathParams(typeSchemas.pathParams, { typed: true, casing: paramsCasing }),
|
|
73
75
|
optional: isOptional(typeSchemas.pathParams?.schema),
|
|
74
76
|
}
|
|
75
77
|
: undefined,
|
|
@@ -108,10 +110,11 @@ export function Client({
|
|
|
108
110
|
parser,
|
|
109
111
|
zodSchemas,
|
|
110
112
|
paramsType,
|
|
113
|
+
paramsCasing,
|
|
111
114
|
pathParamsType,
|
|
112
115
|
operation,
|
|
113
116
|
}: Props): KubbNode {
|
|
114
|
-
const path = new URLPath(operation.path)
|
|
117
|
+
const path = new URLPath(operation.path, { casing: paramsCasing })
|
|
115
118
|
const contentType = operation.getContentType()
|
|
116
119
|
const isFormData = contentType === 'multipart/form-data'
|
|
117
120
|
const headers = [
|
|
@@ -124,7 +127,7 @@ export function Client({
|
|
|
124
127
|
typeSchemas.errors?.map((item) => item.name).join(' | ') || 'Error',
|
|
125
128
|
typeSchemas.request?.name || 'unknown',
|
|
126
129
|
].filter(Boolean)
|
|
127
|
-
const params = getParams({ paramsType, pathParamsType, typeSchemas })
|
|
130
|
+
const params = getParams({ paramsType, paramsCasing, pathParamsType, typeSchemas })
|
|
128
131
|
const clientParams = FunctionParams.factory({
|
|
129
132
|
config: {
|
|
130
133
|
mode: 'object',
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import client from
|
|
3
|
-
import type { RequestConfig } from
|
|
2
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* @description delete a pet
|
|
7
7
|
* @summary Deletes a pet
|
|
8
8
|
* {@link /pet/:petId}
|
|
9
9
|
*/
|
|
10
|
-
export async function deletePet(petId: DeletePetPathParams[
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export async function deletePet(petId: DeletePetPathParams['petId'], headers?: DeletePetHeaderParams, config: Partial<RequestConfig> = {}) {
|
|
11
|
+
const res = await client<DeletePetMutationResponse, DeletePet400, unknown>({
|
|
12
|
+
method: 'DELETE',
|
|
13
|
+
url: `/pet/${petId}`,
|
|
14
|
+
headers: { ...headers, ...config.headers },
|
|
15
|
+
...config,
|
|
16
|
+
})
|
|
17
|
+
return res.data
|
|
13
18
|
}
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import client from
|
|
3
|
-
import type { RequestConfig } from
|
|
2
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* @description delete a pet
|
|
7
7
|
* @summary Deletes a pet
|
|
8
8
|
* {@link /pet/:petId}
|
|
9
9
|
*/
|
|
10
|
-
export async function deletePet({ petId }: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
export async function deletePet({ petId }: { petId: DeletePetPathParams['petId'] }, headers?: DeletePetHeaderParams, config: Partial<RequestConfig> = {}) {
|
|
11
|
+
const res = await client<DeletePetMutationResponse, DeletePet400, unknown>({
|
|
12
|
+
method: 'DELETE',
|
|
13
|
+
url: `/pet/${petId}`,
|
|
14
|
+
headers: { ...headers, ...config.headers },
|
|
15
|
+
...config,
|
|
16
|
+
})
|
|
17
|
+
return res.data
|
|
15
18
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import client from
|
|
3
|
-
import type { RequestConfig } from
|
|
2
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
7
7
|
* @summary Finds Pets by tags
|
|
8
8
|
* {@link /pet/findByTags}
|
|
9
9
|
*/
|
|
10
10
|
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
|
|
12
|
+
return res.data
|
|
13
13
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import client from
|
|
3
|
-
import type { RequestConfig } from
|
|
2
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
7
7
|
* @summary Finds Pets by tags
|
|
8
8
|
* {@link /pet/findByTags}
|
|
9
9
|
*/
|
|
10
10
|
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
|
|
12
|
+
return res
|
|
13
13
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import client from
|
|
3
|
-
import type { RequestConfig } from
|
|
2
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
7
7
|
* @summary Finds Pets by tags
|
|
8
8
|
* {@link /pet/findByTags}
|
|
9
9
|
*/
|
|
10
|
-
export async function findPetsByTags({ params }: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: "GET", url: `/pet/findByTags`, params, ...config });
|
|
14
|
-
return res.data;
|
|
10
|
+
export async function findPetsByTags({ params }: { params?: FindPetsByTagsQueryParams }, config: Partial<RequestConfig> = {}) {
|
|
11
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
|
|
12
|
+
return res.data
|
|
15
13
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import client from
|
|
3
|
-
import type { RequestConfig } from
|
|
2
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
7
7
|
* @summary Finds Pets by tags
|
|
8
8
|
* {@link /pet/findByTags}
|
|
9
9
|
*/
|
|
10
10
|
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
|
|
12
|
+
return findPetsByTagsQueryResponse.parse(res.data)
|
|
13
13
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import client from
|
|
3
|
-
import type { RequestConfig } from
|
|
2
|
+
import client from '@kubb/plugin-client/clients/axios'
|
|
3
|
+
import type { RequestConfig } from '@kubb/plugin-client/clients/axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
7
7
|
* @summary Finds Pets by tags
|
|
8
8
|
* {@link /pet/findByTags}
|
|
9
9
|
*/
|
|
10
10
|
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
|
|
12
|
+
return { ...res, data: findPetsByTagsQueryResponse.parse(res.data) }
|
|
13
13
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
|
-
import client from
|
|
3
|
-
import type { RequestConfig } from
|
|
2
|
+
import client from 'axios'
|
|
3
|
+
import type { RequestConfig } from 'axios'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
6
|
* @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
|
7
7
|
* @summary Finds Pets by tags
|
|
8
8
|
* {@link /pet/findByTags}
|
|
9
9
|
*/
|
|
10
10
|
export async function findPetsByTags(params?: FindPetsByTagsQueryParams, config: Partial<RequestConfig> = {}) {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const res = await client<FindPetsByTagsQueryResponse, FindPetsByTags400, unknown>({ method: 'GET', url: `/pet/findByTags`, params, ...config })
|
|
12
|
+
return res.data
|
|
13
13
|
}
|