diff --git a/packages/openapi-fetch/src/index.js b/packages/openapi-fetch/src/index.js index b54435a55..be3b153a3 100644 --- a/packages/openapi-fetch/src/index.js +++ b/packages/openapi-fetch/src/index.js @@ -597,7 +597,7 @@ export function defaultPathSerializer(pathname, pathParams) { * @type {import("./index.js").defaultBodySerializer} */ export function defaultBodySerializer(body, headers) { - if (body instanceof FormData || typeof body === "string" || body instanceof URLSearchParams || body instanceof Blob) { + if (body instanceof FormData) { return body; } if (headers) { diff --git a/packages/openapi-fetch/test/common/request.test.ts b/packages/openapi-fetch/test/common/request.test.ts index edb773e89..7aa87e563 100644 --- a/packages/openapi-fetch/test/common/request.test.ts +++ b/packages/openapi-fetch/test/common/request.test.ts @@ -213,32 +213,30 @@ describe("request", () => { }); test.each(BODY_ACCEPTING_METHODS)("`''` body (with body serializer) - %s", async (method) => { - const body = '' const bodySerializer = vi.fn((body) => `Serialized: ${JSON.stringify(body)}`); const { bodyUsed, bodyText } = await fireRequestAndGetBodyInformation({ bodySerializer, method, fetchOptions: { - body, + body: "", }, }); expect(bodyUsed).toBe(true); - expect(bodyText).toBe(`Serialized: ${body}`); + expect(bodyText).toBe('Serialized: ""'); expect(bodySerializer).toBeCalled(); }); test.each(BODY_ACCEPTING_METHODS)("`''` body (without body serializer) - %s", async (method) => { - const body = '' const { bodyUsed, bodyText } = await fireRequestAndGetBodyInformation({ method, fetchOptions: { - body, + body: "", }, }); expect(bodyUsed).toBe(true); - expect(bodyText).toBe(body); + expect(bodyText).toBe('""'); }); test.each(BODY_ACCEPTING_METHODS)("`0` body (with body serializer) - %s", async (method) => {