@kubb/plugin-axios 5.2.1 → 5.2.2
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 +3 -3
- package/templates/serializers.ts +9 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-axios",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.2",
|
|
4
4
|
"description": "Generate a slim, type-safe HTTP client with Kubb based on axios.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api-client",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"@internals/client": "0.0.0",
|
|
69
69
|
"@internals/shared": "0.0.0",
|
|
70
70
|
"axios": "^1.20.0",
|
|
71
|
-
"kubb": "^5.0.
|
|
71
|
+
"kubb": "^5.0.6",
|
|
72
72
|
"typescript": "^6.0.3"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
75
|
"axios": "^1.20.0",
|
|
76
|
-
"kubb": "^5.0.
|
|
76
|
+
"kubb": "^5.0.6"
|
|
77
77
|
},
|
|
78
78
|
"peerDependenciesMeta": {
|
|
79
79
|
"axios": {
|
package/templates/serializers.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
export type HeaderValue = string | number | boolean | null | undefined | object
|
|
2
2
|
export type HeadersInit = Array<[string, HeaderValue]> | Record<string, HeaderValue>
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit`
|
|
6
|
+
* name, which a Node-only project (`@types/node` without the `dom` lib) does not declare.
|
|
7
|
+
*/
|
|
8
|
+
export type RequestBody = NonNullable<RequestInit['body']>
|
|
9
|
+
|
|
4
10
|
/**
|
|
5
11
|
* The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and
|
|
6
12
|
* `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as
|
|
@@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle<QueryStyle> & {
|
|
|
67
73
|
* `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries
|
|
68
74
|
* the per-property OpenAPI `encoding` metadata for form bodies.
|
|
69
75
|
*/
|
|
70
|
-
export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record<string, BodyEncoding> }) =>
|
|
76
|
+
export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record<string, BodyEncoding> }) => RequestBody | undefined
|
|
71
77
|
|
|
72
78
|
/**
|
|
73
79
|
* The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value;
|
|
@@ -111,7 +117,7 @@ export type Styles = {
|
|
|
111
117
|
body?: Record<string, BodyEncoding>
|
|
112
118
|
}
|
|
113
119
|
|
|
114
|
-
function isFormBody(body: unknown): body is
|
|
120
|
+
function isFormBody(body: unknown): body is RequestBody {
|
|
115
121
|
return (
|
|
116
122
|
body instanceof FormData ||
|
|
117
123
|
body instanceof URLSearchParams ||
|
|
@@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData:
|
|
|
163
169
|
*/
|
|
164
170
|
export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => {
|
|
165
171
|
if (body === undefined || body === null) return undefined
|
|
166
|
-
if (isFormBody(body)) return body as
|
|
172
|
+
if (isFormBody(body)) return body as RequestBody
|
|
167
173
|
if (contentType?.includes('multipart/form-data')) {
|
|
168
174
|
const formData = new FormData()
|
|
169
175
|
for (const [key, value] of Object.entries(body as Record<string, unknown>)) {
|