diff --git a/.changeset/lazy-plugs-yell.md b/.changeset/lazy-plugs-yell.md new file mode 100644 index 000000000..5647e54a0 --- /dev/null +++ b/.changeset/lazy-plugs-yell.md @@ -0,0 +1,6 @@ +--- +'@kubb/plugin-fetch': patch +'@kubb/plugin-axios': patch +--- + +Fix the generated client failing to type-check in Node-only projects (`@types/node` without the `dom` lib). The generated `.kubb/client.ts` and `.kubb/serializers.ts` no longer reference the global `BodyInit` name, which such a project never declares. They now use a local `RequestBody` type derived from `RequestInit['body']`. diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 42a7451e0..0d9860aa6 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -303,4 +303,4 @@ jobs: NODE_OPTIONS: '--max_old_space_size=4096' KUBB_DISABLE_TELEMETRY: '1' run: | - pnpm run generate --debug + pnpm run generate --reporter file diff --git a/examples/advanced/src/gen/.kubb/serializers.ts b/examples/advanced/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/advanced/src/gen/.kubb/serializers.ts +++ b/examples/advanced/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/examples/axios/src/gen/.kubb/serializers.ts b/examples/axios/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/axios/src/gen/.kubb/serializers.ts +++ b/examples/axios/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/examples/fetch/src/gen/.kubb/client.ts b/examples/fetch/src/gen/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/examples/fetch/src/gen/.kubb/client.ts +++ b/examples/fetch/src/gen/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/examples/fetch/src/gen/.kubb/serializers.ts b/examples/fetch/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/fetch/src/gen/.kubb/serializers.ts +++ b/examples/fetch/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/examples/mcp/src/gen/.kubb/serializers.ts b/examples/mcp/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/mcp/src/gen/.kubb/serializers.ts +++ b/examples/mcp/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/examples/react-query/src/gen/.kubb/client.ts b/examples/react-query/src/gen/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/examples/react-query/src/gen/.kubb/client.ts +++ b/examples/react-query/src/gen/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/examples/react-query/src/gen/.kubb/serializers.ts b/examples/react-query/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/react-query/src/gen/.kubb/serializers.ts +++ b/examples/react-query/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/examples/sdk/src/gen/.kubb/client.ts b/examples/sdk/src/gen/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/examples/sdk/src/gen/.kubb/client.ts +++ b/examples/sdk/src/gen/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/examples/sdk/src/gen/.kubb/serializers.ts b/examples/sdk/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/sdk/src/gen/.kubb/serializers.ts +++ b/examples/sdk/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/examples/simple-single/src/gen/.kubb/client.ts b/examples/simple-single/src/gen/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/examples/simple-single/src/gen/.kubb/client.ts +++ b/examples/simple-single/src/gen/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/examples/simple-single/src/gen/.kubb/serializers.ts b/examples/simple-single/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/simple-single/src/gen/.kubb/serializers.ts +++ b/examples/simple-single/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/examples/swr/src/gen/.kubb/client.ts b/examples/swr/src/gen/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/examples/swr/src/gen/.kubb/client.ts +++ b/examples/swr/src/gen/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/examples/swr/src/gen/.kubb/serializers.ts b/examples/swr/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/swr/src/gen/.kubb/serializers.ts +++ b/examples/swr/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/examples/vue-query/src/gen/.kubb/client.ts b/examples/vue-query/src/gen/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/examples/vue-query/src/gen/.kubb/client.ts +++ b/examples/vue-query/src/gen/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/examples/vue-query/src/gen/.kubb/serializers.ts b/examples/vue-query/src/gen/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/examples/vue-query/src/gen/.kubb/serializers.ts +++ b/examples/vue-query/src/gen/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/packages/plugin-axios/templates/serializers.ts b/packages/plugin-axios/templates/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/packages/plugin-axios/templates/serializers.ts +++ b/packages/plugin-axios/templates/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/packages/plugin-fetch/templates/fetch.ts b/packages/plugin-fetch/templates/fetch.ts index ea6223eff..4ff6baf71 100644 --- a/packages/plugin-fetch/templates/fetch.ts +++ b/packages/plugin-fetch/templates/fetch.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/packages/plugin-fetch/templates/serializers.ts b/packages/plugin-fetch/templates/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/packages/plugin-fetch/templates/serializers.ts +++ b/packages/plugin-fetch/templates/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginAxios/default/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginAxios/default/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginAxios/default/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginAxios/default/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginAxios/paramsCasing/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginAxios/paramsCasing/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginAxios/paramsCasing/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginAxios/paramsCasing/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginAxios/sdkClass/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginAxios/sdkClass/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginAxios/sdkClass/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginAxios/sdkClass/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginAxios/sdkClassWithName/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginAxios/sdkClassWithName/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginAxios/sdkClassWithName/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginAxios/sdkClassWithName/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginAxios/sdkSingle/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginAxios/sdkSingle/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginAxios/sdkSingle/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginAxios/sdkSingle/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginAxios/zodTypes/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginAxios/zodTypes/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginAxios/zodTypes/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginAxios/zodTypes/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginFetch/default/.kubb/client.ts b/tests/3.0.x/__snapshots__/pluginFetch/default/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/default/.kubb/client.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/default/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/tests/3.0.x/__snapshots__/pluginFetch/default/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginFetch/default/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/default/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/default/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginFetch/paramsCasing/.kubb/client.ts b/tests/3.0.x/__snapshots__/pluginFetch/paramsCasing/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/paramsCasing/.kubb/client.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/paramsCasing/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/tests/3.0.x/__snapshots__/pluginFetch/paramsCasing/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginFetch/paramsCasing/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/paramsCasing/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/paramsCasing/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginFetch/sdkClass/.kubb/client.ts b/tests/3.0.x/__snapshots__/pluginFetch/sdkClass/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/sdkClass/.kubb/client.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/sdkClass/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/tests/3.0.x/__snapshots__/pluginFetch/sdkClass/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginFetch/sdkClass/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/sdkClass/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/sdkClass/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginFetch/sdkClassWithName/.kubb/client.ts b/tests/3.0.x/__snapshots__/pluginFetch/sdkClassWithName/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/sdkClassWithName/.kubb/client.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/sdkClassWithName/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/tests/3.0.x/__snapshots__/pluginFetch/sdkClassWithName/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginFetch/sdkClassWithName/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/sdkClassWithName/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/sdkClassWithName/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginFetch/sdkSingle/.kubb/client.ts b/tests/3.0.x/__snapshots__/pluginFetch/sdkSingle/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/sdkSingle/.kubb/client.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/sdkSingle/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/tests/3.0.x/__snapshots__/pluginFetch/sdkSingle/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginFetch/sdkSingle/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/sdkSingle/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/sdkSingle/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginFetch/zodTypes/.kubb/client.ts b/tests/3.0.x/__snapshots__/pluginFetch/zodTypes/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/zodTypes/.kubb/client.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/zodTypes/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/tests/3.0.x/__snapshots__/pluginFetch/zodTypes/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginFetch/zodTypes/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/zodTypes/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/zodTypes/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginFetch/zodTypesSdk/.kubb/client.ts b/tests/3.0.x/__snapshots__/pluginFetch/zodTypesSdk/.kubb/client.ts index ea6223eff..4ff6baf71 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/zodTypesSdk/.kubb/client.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/zodTypesSdk/.kubb/client.ts @@ -1,5 +1,5 @@ import { applyHeaderStyles, defaultBodySerializer, defaultPathSerializer, defaultQuerySerializer, isDefaultJsonBody, serializeCookies } from './serializers' -import type { HeadersInit, PathParamStyle, PathSerializer, Serializers, Styles } from './serializers' +import type { HeadersInit, PathParamStyle, PathSerializer, RequestBody, Serializers, Styles } from './serializers' import { type StandardSchemaValidator, validateStandardSchema } from './standardSchema' /** @@ -124,7 +124,7 @@ export type Deserializer = (raw: unknown, contentType: string) => T /** * Serializes a request body for a single media type, registered per content type as a codec's `serialize` to encode formats the default serializer does not handle. */ -export type ContentBodySerializer = (body: unknown, contentType?: string) => BodyInit | undefined +export type ContentBodySerializer = (body: unknown, contentType?: string) => RequestBody | undefined /** * A per-content-type codec registered on `codecs`, keyed by content type. `serialize` encodes the @@ -238,7 +238,7 @@ export type ResolvedRequest = { url: string method: string headers: Record - body?: BodyInit + body?: RequestBody signal?: AbortSignal credentials?: RequestCredentials options?: FetchOptions diff --git a/tests/3.0.x/__snapshots__/pluginFetch/zodTypesSdk/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginFetch/zodTypesSdk/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginFetch/zodTypesSdk/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginFetch/zodTypesSdk/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginMcp/excludeByOperationId/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginMcp/excludeByOperationId/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginMcp/excludeByOperationId/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginMcp/excludeByOperationId/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginMcp/groupByTag/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginMcp/groupByTag/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginMcp/groupByTag/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginMcp/groupByTag/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginMcp/includeByTag/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginMcp/includeByTag/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginMcp/includeByTag/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginMcp/includeByTag/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginMcp/paramsCasing/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginMcp/paramsCasing/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginMcp/paramsCasing/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginMcp/paramsCasing/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginMcp/petStore/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginMcp/petStore/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginMcp/petStore/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginMcp/petStore/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginMcp/withClientPlugin/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginMcp/withClientPlugin/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginMcp/withClientPlugin/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginMcp/withClientPlugin/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/excludeByOperationId/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/excludeByOperationId/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/excludeByOperationId/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/excludeByOperationId/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/groupByTag/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/groupByTag/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/groupByTag/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/groupByTag/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/includeByTag/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/includeByTag/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/includeByTag/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/includeByTag/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/infinite/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/infinite/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/infinite/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/infinite/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/mutationDisabled/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/mutationDisabled/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/mutationDisabled/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/mutationDisabled/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/paramsCasing/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/paramsCasing/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/paramsCasing/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/paramsCasing/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/parserZod/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/parserZod/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/parserZod/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/parserZod/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/petStore/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/petStore/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/petStore/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/petStore/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/queryMethods/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/queryMethods/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/queryMethods/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/queryMethods/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/suspense/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/suspense/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/suspense/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/suspense/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginReactQuery/withClientPlugin/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginReactQuery/withClientPlugin/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginReactQuery/withClientPlugin/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginReactQuery/withClientPlugin/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/excludeByOperationId/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/excludeByOperationId/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/excludeByOperationId/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/excludeByOperationId/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/groupByTag/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/groupByTag/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/groupByTag/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/groupByTag/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/includeByTag/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/includeByTag/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/includeByTag/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/includeByTag/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/mutationDisabled/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/mutationDisabled/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/mutationDisabled/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/mutationDisabled/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/paramsCasing/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/paramsCasing/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/paramsCasing/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/paramsCasing/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/parserZod/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/parserZod/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/parserZod/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/parserZod/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/petStore/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/petStore/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/petStore/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/petStore/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/queryDisabled/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/queryDisabled/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/queryDisabled/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/queryDisabled/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/queryMethods/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/queryMethods/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/queryMethods/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/queryMethods/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginSwr/withClientPlugin/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginSwr/withClientPlugin/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginSwr/withClientPlugin/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginSwr/withClientPlugin/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/excludeByOperationId/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/excludeByOperationId/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/excludeByOperationId/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/excludeByOperationId/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/groupByTag/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/groupByTag/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/groupByTag/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/groupByTag/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/includeByTag/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/includeByTag/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/includeByTag/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/includeByTag/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/infinite/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/infinite/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/infinite/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/infinite/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/mutationDisabled/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/mutationDisabled/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/mutationDisabled/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/mutationDisabled/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/paramsCasing/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/paramsCasing/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/paramsCasing/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/paramsCasing/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/parserZod/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/parserZod/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/parserZod/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/parserZod/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/petStore/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/petStore/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/petStore/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/petStore/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) { diff --git a/tests/3.0.x/__snapshots__/pluginVueQuery/withClientPlugin/.kubb/serializers.ts b/tests/3.0.x/__snapshots__/pluginVueQuery/withClientPlugin/.kubb/serializers.ts index dd2b2e1fc..d928f56c7 100644 --- a/tests/3.0.x/__snapshots__/pluginVueQuery/withClientPlugin/.kubb/serializers.ts +++ b/tests/3.0.x/__snapshots__/pluginVueQuery/withClientPlugin/.kubb/serializers.ts @@ -1,6 +1,12 @@ export type HeaderValue = string | number | boolean | null | undefined | object export type HeadersInit = Array<[string, HeaderValue]> | Record +/** + * The request body type `fetch` accepts, derived from `RequestInit` instead of the global `BodyInit` + * name, which a Node-only project (`@types/node` without the `dom` lib) does not declare. + */ +export type RequestBody = NonNullable + /** * The OpenAPI query-parameter serialization style. `form` is the default; `spaceDelimited` and * `pipeDelimited` join arrays with a space or pipe, and `deepObject` renders objects as @@ -67,7 +73,7 @@ export type BodyEncoding = SerializationStyle & { * `ArrayBuffer`, and string bodies pass through untouched. The optional `encoding` argument carries * the per-property OpenAPI `encoding` metadata for form bodies. */ -export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => BodyInit | undefined +export type BodySerializer = (args: { body: unknown; contentType?: string; encoding?: Record }) => RequestBody | undefined /** * The OpenAPI path-parameter serialization style. `simple` is the default and emits the bare value; @@ -111,7 +117,7 @@ export type Styles = { body?: Record } -function isFormBody(body: unknown): body is BodyInit { +function isFormBody(body: unknown): body is RequestBody { return ( body instanceof FormData || body instanceof URLSearchParams || @@ -163,7 +169,7 @@ function appendFormDataValue({ formData, key, value, contentType }: { formData: */ export const defaultBodySerializer: BodySerializer = ({ body, contentType, encoding }) => { if (body === undefined || body === null) return undefined - if (isFormBody(body)) return body as BodyInit + if (isFormBody(body)) return body as RequestBody if (contentType?.includes('multipart/form-data')) { const formData = new FormData() for (const [key, value] of Object.entries(body as Record)) {