From 662300b7fa164530f36c9de14d4a283ee2e19fbc Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Sat, 30 Aug 2025 12:47:41 -0400 Subject: [PATCH 01/13] fix(client-fetch): ensures plain/text body is sent with request resolves: #2553 --- .../client-fetch/__tests__/client.test.ts | 92 +++++++++++++++++++ .../@hey-api/client-fetch/bundle/client.ts | 7 +- 2 files changed, 97 insertions(+), 2 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts index 6937bf9b3..06181052d 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it, vi } from 'vitest'; +import type { ResolvedRequestOptions } from '../bundle'; import { createClient } from '../bundle/client'; type MockFetch = ((...args: any[]) => any) & { @@ -221,3 +222,94 @@ describe('zero-length body handling', () => { expect((result.data as Blob).size).toBeGreaterThan(0); }); }); + +describe('request body handling', () => { + const client = createClient({ baseUrl: 'https://example.com' }); + + const scenarios = [ + { + body: 'test string', + bodySerializer: null, + contentType: 'text/plain', + expectedSerializedValue: undefined, + expectedValue: async (request: Request) => await request.text(), + }, + { + body: { key: 'value' }, + bodySerializer: (body: object) => JSON.stringify(body), + contentType: 'application/json', + expectedSerializedValue: '{"key":"value"}', + expectedValue: async (request: Request) => await request.json(), + }, + ]; + + it.each(scenarios)( + 'sends $contentType body', + async ({ body, bodySerializer, contentType, expectedValue }) => { + const mockResponse = new Response(JSON.stringify({ success: true }), { + headers: { + 'Content-Type': 'application/json', + }, + status: 200, + }); + + const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); + + const result = await client.post({ + body, + bodySerializer, + fetch: mockFetch, + headers: { + 'Content-Type': contentType, + }, + url: '/test', + }); + + await expect(expectedValue(result.request)).resolves.toEqual(body); + expect(result.request.headers.get('Content-Type')).toContain(contentType); + }, + ); + + it.each(scenarios)( + 'exposes $contentType serialized and raw body in interceptor', + async ({ body, bodySerializer, contentType, expectedSerializedValue }) => { + const mockResponse = new Response(JSON.stringify({ success: true }), { + headers: { + 'Content-Type': 'application/json', + }, + status: 200, + }); + + const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); + + const mockRequestInterceptor = vi + .fn() + .mockImplementation( + (request: Request, options: ResolvedRequestOptions) => { + expect(options.serializedBody).toBe(expectedSerializedValue); + expect(options.body).toBe(body); + + return request; + }, + ); + + const interceptorId = client.interceptors.request.use( + mockRequestInterceptor, + ); + + await client.post({ + body, + bodySerializer, + fetch: mockFetch, + headers: { + 'Content-Type': contentType, + }, + url: '/test', + }); + + expect(mockRequestInterceptor).toHaveBeenCalledOnce(); + + client.interceptors.request.eject(interceptorId); + }, + ); +}); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts index 3615a16ac..cd9966528 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts @@ -63,7 +63,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -78,9 +78,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { From 9320253eb88172a4d1f41f1429ed63c7379f79ca Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Sat, 30 Aug 2025 23:30:05 -0400 Subject: [PATCH 02/13] fix(client-next): ensures plain/text body is sent with request refs: #2553 --- .../client-next/__tests__/client.test.ts | 100 +++++++++++++++++- .../@hey-api/client-next/bundle/client.ts | 13 ++- 2 files changed, 108 insertions(+), 5 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts index 9b7aa96d8..35723cee1 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts @@ -1,6 +1,11 @@ -import { describe, expect, it } from 'vitest'; +import { describe, expect, it, vi } from 'vitest'; import { createClient } from '../bundle/client'; +import type { ResolvedRequestOptions } from '../bundle/types'; + +type MockFetch = ((...args: any[]) => any) & { + preconnect?: any; +}; describe('buildUrl', () => { const client = createClient(); @@ -48,3 +53,96 @@ describe('buildUrl', () => { expect(client.buildUrl(options)).toBe(url); }); }); + +describe('request body handling', () => { + const client = createClient({ baseUrl: 'https://example.com' }); + + const scenarios = [ + { + body: 'test string', + bodySerializer: null, + contentType: 'text/plain', + expectedSerializedValue: undefined, + expectedValue: 'test string', + }, + { + body: { key: 'value' }, + bodySerializer: (body: object) => JSON.stringify(body), + contentType: 'application/json', + expectedSerializedValue: '{"key":"value"}', + expectedValue: '{"key":"value"}', + }, + ]; + + it.each(scenarios)( + 'sends $contentType body', + async ({ body, bodySerializer, contentType, expectedValue }) => { + const mockResponse = new Response(JSON.stringify({ success: true }), { + headers: { + 'Content-Type': 'application/json', + }, + status: 200, + }); + + const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); + const headers = new Headers({ 'Content-Type': contentType }); + + await client.post({ + body, + bodySerializer, + fetch: mockFetch, + headers, + url: '/test', + }); + + expect(mockFetch).toHaveBeenCalledExactlyOnceWith( + expect.any(String), + expect.objectContaining({ + body: expectedValue, + headers, + }), + ); + }, + ); + + it.each(scenarios)( + 'exposes $contentType serialized and raw body in interceptor', + async ({ body, bodySerializer, contentType, expectedSerializedValue }) => { + const mockResponse = new Response(JSON.stringify({ success: true }), { + headers: { + 'Content-Type': 'application/json', + }, + status: 200, + }); + + const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); + + const mockRequestInterceptor = vi + .fn() + .mockImplementation((options: ResolvedRequestOptions) => { + expect(options.serializedBody).toBe(expectedSerializedValue); + expect(options.body).toBe(body); + + return options; + }); + + const interceptorId = client.interceptors.request.use( + mockRequestInterceptor, + ); + + await client.post({ + body, + bodySerializer, + fetch: mockFetch, + headers: { + 'Content-Type': contentType, + }, + url: '/test', + }); + + expect(mockRequestInterceptor).toHaveBeenCalledOnce(); + + client.interceptors.request.eject(interceptorId); + }, + ); +}); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index f59fe1934..a6322c6d1 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -62,7 +62,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -85,10 +85,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { From b4d06c60792f2bd416b3ed9b992c61261a9fc71e Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Sat, 30 Aug 2025 23:57:09 -0400 Subject: [PATCH 03/13] test(client): updates snapshots refs: #2553 --- .../body-response-text-plain/client/client.gen.ts | 7 +++++-- .../2.0.x/form-data/client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../sdk-nested-classes/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/default/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/instance/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/throwOnError/client/client.gen.ts | 7 +++++-- .../type-format-valibot/client/client.gen.ts | 7 +++++-- .../type-format-zod/client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../@pinia/colada/fetch/client/client.gen.ts | 7 +++++-- .../@pinia/colada/group-by-tag/client/client.gen.ts | 7 +++++-- .../asClass/client/client.gen.ts | 7 +++++-- .../fetch/client/client.gen.ts | 7 +++++-- .../name-builder/client/client.gen.ts | 7 +++++-- .../react-query/asClass/client/client.gen.ts | 7 +++++-- .../react-query/fetch/client/client.gen.ts | 7 +++++-- .../react-query/name-builder/client/client.gen.ts | 7 +++++-- .../solid-query/asClass/client/client.gen.ts | 7 +++++-- .../solid-query/fetch/client/client.gen.ts | 7 +++++-- .../solid-query/name-builder/client/client.gen.ts | 7 +++++-- .../svelte-query/asClass/client/client.gen.ts | 7 +++++-- .../svelte-query/fetch/client/client.gen.ts | 7 +++++-- .../svelte-query/name-builder/client/client.gen.ts | 7 +++++-- .../vue-query/asClass/client/client.gen.ts | 7 +++++-- .../@tanstack/vue-query/fetch/client/client.gen.ts | 7 +++++-- .../vue-query/name-builder/client/client.gen.ts | 7 +++++-- .../2.0.x/schema-unknown/client/client.gen.ts | 7 +++++-- .../2.0.x/security-api-key/client/client.gen.ts | 7 +++++-- .../2.0.x/security-basic/client/client.gen.ts | 7 +++++-- .../2.0.x/security-false/client/client.gen.ts | 7 +++++-- .../2.0.x/security-oauth2/client/client.gen.ts | 7 +++++-- .../2.0.x/servers-base-path/client/client.gen.ts | 7 +++++-- .../2.0.x/servers-host/client/client.gen.ts | 7 +++++-- .../2.0.x/servers/client/client.gen.ts | 7 +++++-- .../transforms-read-write/client/client.gen.ts | 7 +++++-- .../body-response-text-plain/client/client.gen.ts | 7 +++++-- .../internal-name-conflict/client/client.gen.ts | 7 +++++-- .../parameter-explode-false/client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../sdk-nested-classes/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/default/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/instance/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/throwOnError/client/client.gen.ts | 7 +++++-- .../type-format-valibot/client/client.gen.ts | 7 +++++-- .../type-format-zod/client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../@pinia/colada/fetch/client/client.gen.ts | 7 +++++-- .../@pinia/colada/group-by-tag/client/client.gen.ts | 7 +++++-- .../asClass/client/client.gen.ts | 7 +++++-- .../fetch/client/client.gen.ts | 7 +++++-- .../name-builder/client/client.gen.ts | 7 +++++-- .../react-query/asClass/client/client.gen.ts | 7 +++++-- .../react-query/fetch/client/client.gen.ts | 7 +++++-- .../react-query/name-builder/client/client.gen.ts | 7 +++++-- .../solid-query/asClass/client/client.gen.ts | 7 +++++-- .../solid-query/fetch/client/client.gen.ts | 7 +++++-- .../solid-query/name-builder/client/client.gen.ts | 7 +++++-- .../svelte-query/asClass/client/client.gen.ts | 7 +++++-- .../svelte-query/fetch/client/client.gen.ts | 7 +++++-- .../svelte-query/name-builder/client/client.gen.ts | 7 +++++-- .../vue-query/asClass/client/client.gen.ts | 7 +++++-- .../@tanstack/vue-query/fetch/client/client.gen.ts | 7 +++++-- .../vue-query/name-builder/client/client.gen.ts | 7 +++++-- .../3.0.x/security-api-key/client/client.gen.ts | 7 +++++-- .../3.0.x/security-false/client/client.gen.ts | 7 +++++-- .../3.0.x/security-http-bearer/client/client.gen.ts | 7 +++++-- .../3.0.x/security-oauth2/client/client.gen.ts | 7 +++++-- .../security-open-id-connect/client/client.gen.ts | 7 +++++-- .../3.0.x/servers/client/client.gen.ts | 7 +++++-- .../3.0.x/transformers-all-of/client/client.gen.ts | 7 +++++-- .../transformers-any-of-null/client/client.gen.ts | 7 +++++-- .../3.0.x/transformers-array/client/client.gen.ts | 7 +++++-- .../transforms-read-write/client/client.gen.ts | 7 +++++-- .../body-response-text-plain/client/client.gen.ts | 7 +++++-- .../base-url-false/client/client.gen.ts | 7 +++++-- .../base-url-number/client/client.gen.ts | 7 +++++-- .../base-url-strict/client/client.gen.ts | 7 +++++-- .../base-url-string/client/client.gen.ts | 7 +++++-- .../client-fetch/clean-false/client/client.gen.ts | 7 +++++-- .../client-fetch/default/client/client.gen.ts | 7 +++++-- .../sdk-client-optional/client/client.gen.ts | 7 +++++-- .../sdk-client-required/client/client.gen.ts | 7 +++++-- .../tsconfig-nodenext-sdk/client/client.gen.ts | 7 +++++-- .../client-next/base-url-false/client/client.gen.ts | 13 +++++++++---- .../base-url-number/client/client.gen.ts | 13 +++++++++---- .../base-url-strict/client/client.gen.ts | 13 +++++++++---- .../base-url-string/client/client.gen.ts | 13 +++++++++---- .../client-next/clean-false/client/client.gen.ts | 13 +++++++++---- .../client-next/default/client/client.gen.ts | 13 +++++++++---- .../sdk-client-optional/client/client.gen.ts | 13 +++++++++---- .../sdk-client-required/client/client.gen.ts | 13 +++++++++---- .../tsconfig-nodenext-sdk/client/client.gen.ts | 13 +++++++++---- .../3.1.x/headers/client/client.gen.ts | 7 +++++-- .../internal-name-conflict/client/client.gen.ts | 7 +++++-- .../3.1.x/pagination-ref/client/client.gen.ts | 7 +++++-- .../parameter-explode-false/client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../sdk-nested-classes/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/default/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/instance/client/client.gen.ts | 7 +++++-- .../@hey-api/sdk/throwOnError/client/client.gen.ts | 7 +++++-- .../type-format-valibot/client/client.gen.ts | 7 +++++-- .../type-format-zod/client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../client/client.gen.ts | 7 +++++-- .../@pinia/colada/fetch/client/client.gen.ts | 7 +++++-- .../@pinia/colada/group-by-tag/client/client.gen.ts | 7 +++++-- .../asClass/client/client.gen.ts | 7 +++++-- .../fetch/client/client.gen.ts | 7 +++++-- .../name-builder/client/client.gen.ts | 7 +++++-- .../react-query/asClass/client/client.gen.ts | 7 +++++-- .../react-query/fetch/client/client.gen.ts | 7 +++++-- .../react-query/name-builder/client/client.gen.ts | 7 +++++-- .../solid-query/asClass/client/client.gen.ts | 7 +++++-- .../solid-query/fetch/client/client.gen.ts | 7 +++++-- .../solid-query/name-builder/client/client.gen.ts | 7 +++++-- .../svelte-query/asClass/client/client.gen.ts | 7 +++++-- .../svelte-query/fetch/client/client.gen.ts | 7 +++++-- .../svelte-query/name-builder/client/client.gen.ts | 7 +++++-- .../vue-query/asClass/client/client.gen.ts | 7 +++++-- .../@tanstack/vue-query/fetch/client/client.gen.ts | 7 +++++-- .../vue-query/name-builder/client/client.gen.ts | 7 +++++-- .../3.1.x/security-api-key/client/client.gen.ts | 7 +++++-- .../3.1.x/security-false/client/client.gen.ts | 7 +++++-- .../3.1.x/security-http-bearer/client/client.gen.ts | 7 +++++-- .../3.1.x/security-oauth2/client/client.gen.ts | 7 +++++-- .../security-open-id-connect/client/client.gen.ts | 7 +++++-- .../3.1.x/servers/client/client.gen.ts | 7 +++++-- .../3.1.x/sse-fetch/client/client.gen.ts | 7 +++++-- .../3.1.x/sse-next/client/client.gen.ts | 13 +++++++++---- .../3.1.x/transformers-all-of/client/client.gen.ts | 7 +++++-- .../transformers-any-of-null/client/client.gen.ts | 7 +++++-- .../3.1.x/transformers-array/client/client.gen.ts | 7 +++++-- .../transforms-read-write/client/client.gen.ts | 7 +++++-- .../plugins/@tanstack/meta/client/client.gen.ts | 7 +++++-- .../generated/v3_no_index/client/client.gen.ts.snap | 7 +++++-- 139 files changed, 735 insertions(+), 298 deletions(-) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts index 136c0eb5d..55d5140a5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts index 3c5df8c21..1b6204c57 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts index 9a3f20891..17450b9b5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts @@ -64,7 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -87,10 +87,15 @@ export const createClient = (config: Config = {}): Client => { // fetch must be assigned here, otherwise it would throw the error: // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation const _fetch = opts.fetch!; - let response = await _fetch(url, { + const requestInit: ReqInit = { ...opts, - body: opts.serializedBody as ReqInit['body'], - }); + }; + + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + + let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { if (fn) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap index f68339318..ff0238aec 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap @@ -65,7 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.body === '') { opts.headers.delete('Content-Type'); } @@ -80,9 +80,12 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, - body: opts.serializedBody, }; + if (opts.serializedBody) { + requestInit.body = opts.serializedBody; + } + let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { From 4064f51aaf262401f186e422b124143a4df09b99 Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Mon, 1 Sep 2025 10:51:27 -0400 Subject: [PATCH 04/13] fix(client-fetch): ensures valid serialized or unserialized body is sent with request refs: #2553 --- .../client-fetch/__tests__/client.test.ts | 126 +++++++++++++++--- .../@hey-api/client-fetch/bundle/client.ts | 29 +++- 2 files changed, 131 insertions(+), 24 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts index 06181052d..b99f0823e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts @@ -223,29 +223,88 @@ describe('zero-length body handling', () => { }); }); -describe('request body handling', () => { +describe('unserialized request body handling', () => { + const client = createClient({ baseUrl: 'https://example.com' }); + + const scenarios = [ + { body: 0, textValue: '0' }, + { body: false, textValue: 'false' }, + { body: 'test string', textValue: 'test string' }, + { body: '', textValue: '' }, + ]; + + it.each(scenarios)( + 'handles plain text body with $body value', + async ({ body, textValue }) => { + const mockResponse = new Response(JSON.stringify({ success: true }), { + headers: { + 'Content-Type': 'application/json', + }, + status: 200, + }); + + const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); + + const result = await client.post({ + body, + bodySerializer: null, + fetch: mockFetch, + headers: { + 'Content-Type': 'text/plain', + }, + url: '/test', + }); + + expect(mockFetch).toHaveBeenCalledWith( + expect.objectContaining({ + body: expect.any(ReadableStream), + }), + ); + + await expect(result.request.text()).resolves.toEqual(textValue); + expect(result.request.headers.get('Content-Type')).toEqual('text/plain'); + }, + ); +}); + +describe('serialized request body handling', () => { const client = createClient({ baseUrl: 'https://example.com' }); const scenarios = [ { - body: 'test string', - bodySerializer: null, - contentType: 'text/plain', - expectedSerializedValue: undefined, - expectedValue: async (request: Request) => await request.text(), + expectBodyValue: false, + expectContentHeader: false, + serializedBody: '', + textValue: '', }, { - body: { key: 'value' }, - bodySerializer: (body: object) => JSON.stringify(body), - contentType: 'application/json', - expectedSerializedValue: '{"key":"value"}', - expectedValue: async (request: Request) => await request.json(), + expectBodyValue: true, + expectContentHeader: true, + serializedBody: 0, + textValue: '0', + }, + { + expectBodyValue: true, + expectContentHeader: true, + serializedBody: false, + textValue: 'false', + }, + { + expectBodyValue: true, + expectContentHeader: true, + serializedBody: '{"key":"value"}', + textValue: '{"key":"value"}', }, ]; it.each(scenarios)( - 'sends $contentType body', - async ({ body, bodySerializer, contentType, expectedValue }) => { + 'handles $serializedBody serializedBody', + async ({ + expectBodyValue, + expectContentHeader, + serializedBody, + textValue, + }) => { const mockResponse = new Response(JSON.stringify({ success: true }), { headers: { 'Content-Type': 'application/json', @@ -256,22 +315,51 @@ describe('request body handling', () => { const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); const result = await client.post({ - body, - bodySerializer, + body: {}, + bodySerializer: () => serializedBody, fetch: mockFetch, headers: { - 'Content-Type': contentType, + 'Content-Type': 'application/json', }, url: '/test', }); - await expect(expectedValue(result.request)).resolves.toEqual(body); - expect(result.request.headers.get('Content-Type')).toContain(contentType); + expect(mockFetch).toHaveBeenCalledWith( + expect.objectContaining({ + body: expectBodyValue ? expect.any(ReadableStream) : null, + }), + ); + + await expect(result.request.text()).resolves.toEqual(textValue); + expect(result.request.headers.get('Content-Type')).toEqual( + expectContentHeader ? 'application/json' : null, + ); }, ); +}); + +describe('request interceptor', () => { + const client = createClient({ baseUrl: 'https://example.com' }); + + const scenarios = [ + { + body: 'test string', + bodySerializer: null, + contentType: 'text/plain', + expectedSerializedValue: undefined, + expectedValue: async (request: Request) => await request.text(), + }, + { + body: { key: 'value' }, + bodySerializer: (body: object) => JSON.stringify(body), + contentType: 'application/json', + expectedSerializedValue: '{"key":"value"}', + expectedValue: async (request: Request) => await request.json(), + }, + ]; it.each(scenarios)( - 'exposes $contentType serialized and raw body in interceptor', + 'exposes $contentType serialized and raw body values', async ({ body, bodySerializer, contentType, expectedSerializedValue }) => { const mockResponse = new Response(JSON.stringify({ success: true }), { headers: { diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts index cd9966528..397399cf1 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts @@ -63,7 +63,10 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -78,12 +81,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -213,6 +213,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); From 3b2ca4ef1376761f020fdcee0f092bd97eba626b Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Tue, 2 Sep 2025 07:16:31 -0400 Subject: [PATCH 05/13] fix(client-fetch): ensures request body can be serialized when defined refs: #2553 --- .../@hey-api/client-fetch/__tests__/client.test.ts | 9 +++++++-- .../src/plugins/@hey-api/client-fetch/bundle/client.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts index b99f0823e..856996390 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts @@ -272,24 +272,28 @@ describe('serialized request body handling', () => { const scenarios = [ { + body: '', expectBodyValue: false, expectContentHeader: false, serializedBody: '', textValue: '', }, { + body: 0, expectBodyValue: true, expectContentHeader: true, serializedBody: 0, textValue: '0', }, { + body: false, expectBodyValue: true, expectContentHeader: true, serializedBody: false, textValue: 'false', }, { + body: {}, expectBodyValue: true, expectContentHeader: true, serializedBody: '{"key":"value"}', @@ -298,8 +302,9 @@ describe('serialized request body handling', () => { ]; it.each(scenarios)( - 'handles $serializedBody serializedBody', + 'handles $serializedBody serializedBody value', async ({ + body, expectBodyValue, expectContentHeader, serializedBody, @@ -315,7 +320,7 @@ describe('serialized request body handling', () => { const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); const result = await client.post({ - body: {}, + body, bodySerializer: () => serializedBody, fetch: mockFetch, headers: { diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts index 397399cf1..7373139c9 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts @@ -58,7 +58,7 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } From 7c3e725ff7b1d23ea8e64530c207ca7c5e3ff500 Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Tue, 2 Sep 2025 07:55:45 -0400 Subject: [PATCH 06/13] fix(client-next): ensures valid serialized or unserialized body is sent with request refs: #2553 --- .../client-next/__tests__/client.test.ts | 113 +++++++++++++++--- .../@hey-api/client-next/bundle/client.ts | 31 ++++- 2 files changed, 120 insertions(+), 24 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts index 35723cee1..61eb654b2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/__tests__/client.test.ts @@ -54,29 +54,83 @@ describe('buildUrl', () => { }); }); -describe('request body handling', () => { +describe('unserialized request body handling', () => { + const client = createClient({ baseUrl: 'https://example.com' }); + + const scenarios = [ + { body: 0 }, + { body: false }, + { body: 'test string' }, + { body: '' }, + ]; + + it.each(scenarios)( + 'handles plain text body with $body value', + async ({ body }) => { + const mockResponse = new Response(JSON.stringify({ success: true }), { + headers: { + 'Content-Type': 'application/json', + }, + status: 200, + }); + + const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); + const headers = new Headers({ 'Content-Type': 'text/plain' }); + + await client.post({ + body, + bodySerializer: null, + fetch: mockFetch, + headers: { + 'Content-Type': 'text/plain', + }, + url: '/test', + }); + + expect(mockFetch).toHaveBeenCalledExactlyOnceWith( + expect.any(String), + expect.objectContaining({ + body, + headers, + }), + ); + }, + ); +}); + +describe('serialized request body handling', () => { const client = createClient({ baseUrl: 'https://example.com' }); const scenarios = [ { - body: 'test string', - bodySerializer: null, - contentType: 'text/plain', - expectedSerializedValue: undefined, - expectedValue: 'test string', + body: '', + expectBodyValue: false, + expectContentHeader: false, + serializedBody: '', }, { - body: { key: 'value' }, - bodySerializer: (body: object) => JSON.stringify(body), - contentType: 'application/json', - expectedSerializedValue: '{"key":"value"}', - expectedValue: '{"key":"value"}', + body: 0, + expectBodyValue: true, + expectContentHeader: true, + serializedBody: 0, + }, + { + body: false, + expectBodyValue: true, + expectContentHeader: true, + serializedBody: false, + }, + { + body: {}, + expectBodyValue: true, + expectContentHeader: true, + serializedBody: '{"key":"value"}', }, ]; it.each(scenarios)( - 'sends $contentType body', - async ({ body, bodySerializer, contentType, expectedValue }) => { + 'handles $serializedBody serializedBody value', + async ({ body, expectBodyValue, expectContentHeader, serializedBody }) => { const mockResponse = new Response(JSON.stringify({ success: true }), { headers: { 'Content-Type': 'application/json', @@ -85,25 +139,48 @@ describe('request body handling', () => { }); const mockFetch: MockFetch = vi.fn().mockResolvedValueOnce(mockResponse); - const headers = new Headers({ 'Content-Type': contentType }); + const headers = new Headers({ 'Content-Type': 'application/json' }); await client.post({ body, - bodySerializer, + bodySerializer: () => serializedBody, fetch: mockFetch, - headers, + headers: { + 'Content-Type': 'application/json', + }, url: '/test', }); expect(mockFetch).toHaveBeenCalledExactlyOnceWith( expect.any(String), expect.objectContaining({ - body: expectedValue, - headers, + body: expectBodyValue ? serializedBody : null, + headers: expectContentHeader ? headers : new Headers(), }), ); }, ); +}); + +describe('request interceptor', () => { + const client = createClient({ baseUrl: 'https://example.com' }); + + const scenarios = [ + { + body: 'test string', + bodySerializer: null, + contentType: 'text/plain', + expectedSerializedValue: undefined, + expectedValue: 'test string', + }, + { + body: { key: 'value' }, + bodySerializer: (body: object) => JSON.stringify(body), + contentType: 'application/json', + expectedSerializedValue: '{"key":"value"}', + expectedValue: '{"key":"value"}', + }, + ]; it.each(scenarios)( 'exposes $contentType serialized and raw body in interceptor', diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index a6322c6d1..18ec4bca8 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -57,12 +57,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -87,12 +90,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -201,6 +201,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); From b1a3658436fa71c2487c935052b8ec13b71492ed Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Tue, 2 Sep 2025 14:42:10 -0400 Subject: [PATCH 07/13] test(client): updates snapshots refs: #2553 --- .../client/client.gen.ts | 31 +++++++++++++++---- .../2.0.x/form-data/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../sdk-nested-classes/client/client.gen.ts | 31 +++++++++++++++---- .../@hey-api/sdk/default/client/client.gen.ts | 31 +++++++++++++++---- .../sdk/instance/client/client.gen.ts | 31 +++++++++++++++---- .../sdk/throwOnError/client/client.gen.ts | 31 +++++++++++++++---- .../type-format-valibot/client/client.gen.ts | 31 +++++++++++++++---- .../type-format-zod/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../@pinia/colada/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../colada/group-by-tag/client/client.gen.ts | 31 +++++++++++++++---- .../asClass/client/client.gen.ts | 31 +++++++++++++++---- .../fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../react-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../react-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../solid-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../solid-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../svelte-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../svelte-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../vue-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../vue-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../2.0.x/schema-unknown/client/client.gen.ts | 31 +++++++++++++++---- .../security-api-key/client/client.gen.ts | 31 +++++++++++++++---- .../2.0.x/security-basic/client/client.gen.ts | 31 +++++++++++++++---- .../2.0.x/security-false/client/client.gen.ts | 31 +++++++++++++++---- .../security-oauth2/client/client.gen.ts | 31 +++++++++++++++---- .../servers-base-path/client/client.gen.ts | 31 +++++++++++++++---- .../2.0.x/servers-host/client/client.gen.ts | 31 +++++++++++++++---- .../2.0.x/servers/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../sdk-nested-classes/client/client.gen.ts | 31 +++++++++++++++---- .../@hey-api/sdk/default/client/client.gen.ts | 31 +++++++++++++++---- .../sdk/instance/client/client.gen.ts | 31 +++++++++++++++---- .../sdk/throwOnError/client/client.gen.ts | 31 +++++++++++++++---- .../type-format-valibot/client/client.gen.ts | 31 +++++++++++++++---- .../type-format-zod/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../@pinia/colada/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../colada/group-by-tag/client/client.gen.ts | 31 +++++++++++++++---- .../asClass/client/client.gen.ts | 31 +++++++++++++++---- .../fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../react-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../react-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../solid-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../solid-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../svelte-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../svelte-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../vue-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../vue-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../security-api-key/client/client.gen.ts | 31 +++++++++++++++---- .../3.0.x/security-false/client/client.gen.ts | 31 +++++++++++++++---- .../security-http-bearer/client/client.gen.ts | 31 +++++++++++++++---- .../security-oauth2/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../3.0.x/servers/client/client.gen.ts | 31 +++++++++++++++---- .../transformers-all-of/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../transformers-array/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../base-url-false/client/client.gen.ts | 31 +++++++++++++++---- .../base-url-number/client/client.gen.ts | 31 +++++++++++++++---- .../base-url-strict/client/client.gen.ts | 31 +++++++++++++++---- .../base-url-string/client/client.gen.ts | 31 +++++++++++++++---- .../clean-false/client/client.gen.ts | 31 +++++++++++++++---- .../client-fetch/default/client/client.gen.ts | 31 +++++++++++++++---- .../sdk-client-optional/client/client.gen.ts | 31 +++++++++++++++---- .../sdk-client-required/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../base-url-false/client/client.gen.ts | 31 +++++++++++++++---- .../base-url-number/client/client.gen.ts | 31 +++++++++++++++---- .../base-url-strict/client/client.gen.ts | 31 +++++++++++++++---- .../base-url-string/client/client.gen.ts | 31 +++++++++++++++---- .../clean-false/client/client.gen.ts | 31 +++++++++++++++---- .../client-next/default/client/client.gen.ts | 31 +++++++++++++++---- .../sdk-client-optional/client/client.gen.ts | 31 +++++++++++++++---- .../sdk-client-required/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../3.1.x/headers/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../3.1.x/pagination-ref/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../sdk-nested-classes/client/client.gen.ts | 31 +++++++++++++++---- .../@hey-api/sdk/default/client/client.gen.ts | 31 +++++++++++++++---- .../sdk/instance/client/client.gen.ts | 31 +++++++++++++++---- .../sdk/throwOnError/client/client.gen.ts | 31 +++++++++++++++---- .../type-format-valibot/client/client.gen.ts | 31 +++++++++++++++---- .../type-format-zod/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../@pinia/colada/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../colada/group-by-tag/client/client.gen.ts | 31 +++++++++++++++---- .../asClass/client/client.gen.ts | 31 +++++++++++++++---- .../fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../react-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../react-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../solid-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../solid-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../svelte-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../svelte-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../vue-query/asClass/client/client.gen.ts | 31 +++++++++++++++---- .../vue-query/fetch/client/client.gen.ts | 31 +++++++++++++++---- .../name-builder/client/client.gen.ts | 31 +++++++++++++++---- .../security-api-key/client/client.gen.ts | 31 +++++++++++++++---- .../3.1.x/security-false/client/client.gen.ts | 31 +++++++++++++++---- .../security-http-bearer/client/client.gen.ts | 31 +++++++++++++++---- .../security-oauth2/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../3.1.x/servers/client/client.gen.ts | 31 +++++++++++++++---- .../3.1.x/sse-fetch/client/client.gen.ts | 31 +++++++++++++++---- .../3.1.x/sse-next/client/client.gen.ts | 31 +++++++++++++++---- .../transformers-all-of/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../transformers-array/client/client.gen.ts | 31 +++++++++++++++---- .../client/client.gen.ts | 31 +++++++++++++++---- .../@tanstack/meta/client/client.gen.ts | 31 +++++++++++++++---- .../v3_no_index/client/client.gen.ts.snap | 31 +++++++++++++++---- 139 files changed, 3475 insertions(+), 834 deletions(-) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts index 55d5140a5..ca4eebad6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts index 1b6204c57..6579f7ab6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts index 17450b9b5..06cae5956 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts @@ -59,12 +59,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -89,12 +92,9 @@ export const createClient = (config: Config = {}): Client => { const _fetch = opts.fetch!; const requestInit: ReqInit = { ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let response = await _fetch(url, requestInit); for (const fn of interceptors.response._fns) { @@ -203,6 +203,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap index ff0238aec..ff7815f4d 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap @@ -60,12 +60,15 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.body === undefined || opts.body === '') { + if ( + opts.body === undefined || + (opts.serializedBody !== undefined && opts.serializedBody === '') + ) { opts.headers.delete('Content-Type'); } @@ -80,12 +83,9 @@ export const createClient = (config: Config = {}): Client => { const requestInit: ReqInit = { redirect: 'follow', ...opts, + body: getValidRequestBody(opts), }; - if (opts.serializedBody) { - requestInit.body = opts.serializedBody; - } - let request = new Request(url, requestInit); for (const fn of interceptors.request._fns) { @@ -215,6 +215,25 @@ export const createClient = (config: Config = {}): Client => { }; }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return null; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); From 244304d65552c900a0ec743e2d69a55a8507b910 Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Tue, 2 Sep 2025 20:48:57 -0400 Subject: [PATCH 08/13] chore(client-fetch,client-nuxt): removes redundant delete header condition --- .../src/plugins/@hey-api/client-fetch/bundle/client.ts | 5 +---- .../src/plugins/@hey-api/client-next/bundle/client.ts | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts index 7373139c9..3e59d949a 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts @@ -63,10 +63,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index 18ec4bca8..3cf237b6e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -62,10 +62,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } From 65c87631e3b03411921d7602b0a96c748f7e9cbb Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Tue, 2 Sep 2025 20:56:25 -0400 Subject: [PATCH 09/13] chore(client): updates snapshots --- .../2.0.x/body-response-text-plain/client/client.gen.ts | 5 +---- .../test/__snapshots__/2.0.x/form-data/client/client.gen.ts | 5 +---- .../sdk-nested-classes-instance/client/client.gen.ts | 5 +---- .../client-fetch/sdk-nested-classes/client/client.gen.ts | 5 +---- .../2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts | 5 +---- .../2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts | 5 +---- .../plugins/@hey-api/sdk/throwOnError/client/client.gen.ts | 5 +---- .../transformers/type-format-valibot/client/client.gen.ts | 5 +---- .../transformers/type-format-zod/client/client.gen.ts | 5 +---- .../transforms-read-write-custom-name/client/client.gen.ts | 5 +---- .../transforms-read-write-ignore/client/client.gen.ts | 5 +---- .../2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts | 5 +---- .../plugins/@pinia/colada/group-by-tag/client/client.gen.ts | 5 +---- .../angular-query-experimental/asClass/client/client.gen.ts | 5 +---- .../angular-query-experimental/fetch/client/client.gen.ts | 5 +---- .../name-builder/client/client.gen.ts | 5 +---- .../@tanstack/react-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/react-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/react-query/name-builder/client/client.gen.ts | 5 +---- .../@tanstack/solid-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/solid-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/solid-query/name-builder/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/asClass/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/name-builder/client/client.gen.ts | 5 +---- .../plugins/@tanstack/vue-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/vue-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/vue-query/name-builder/client/client.gen.ts | 5 +---- .../__snapshots__/2.0.x/schema-unknown/client/client.gen.ts | 5 +---- .../2.0.x/security-api-key/client/client.gen.ts | 5 +---- .../__snapshots__/2.0.x/security-basic/client/client.gen.ts | 5 +---- .../__snapshots__/2.0.x/security-false/client/client.gen.ts | 5 +---- .../__snapshots__/2.0.x/security-oauth2/client/client.gen.ts | 5 +---- .../2.0.x/servers-base-path/client/client.gen.ts | 5 +---- .../__snapshots__/2.0.x/servers-host/client/client.gen.ts | 5 +---- .../test/__snapshots__/2.0.x/servers/client/client.gen.ts | 5 +---- .../2.0.x/transforms-read-write/client/client.gen.ts | 5 +---- .../3.0.x/body-response-text-plain/client/client.gen.ts | 5 +---- .../3.0.x/internal-name-conflict/client/client.gen.ts | 5 +---- .../3.0.x/parameter-explode-false/client/client.gen.ts | 5 +---- .../sdk-nested-classes-instance/client/client.gen.ts | 5 +---- .../client-fetch/sdk-nested-classes/client/client.gen.ts | 5 +---- .../3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts | 5 +---- .../3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts | 5 +---- .../plugins/@hey-api/sdk/throwOnError/client/client.gen.ts | 5 +---- .../transformers/type-format-valibot/client/client.gen.ts | 5 +---- .../transformers/type-format-zod/client/client.gen.ts | 5 +---- .../transforms-read-write-custom-name/client/client.gen.ts | 5 +---- .../transforms-read-write-ignore/client/client.gen.ts | 5 +---- .../3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts | 5 +---- .../plugins/@pinia/colada/group-by-tag/client/client.gen.ts | 5 +---- .../angular-query-experimental/asClass/client/client.gen.ts | 5 +---- .../angular-query-experimental/fetch/client/client.gen.ts | 5 +---- .../name-builder/client/client.gen.ts | 5 +---- .../@tanstack/react-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/react-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/react-query/name-builder/client/client.gen.ts | 5 +---- .../@tanstack/solid-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/solid-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/solid-query/name-builder/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/asClass/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/name-builder/client/client.gen.ts | 5 +---- .../plugins/@tanstack/vue-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/vue-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/vue-query/name-builder/client/client.gen.ts | 5 +---- .../3.0.x/security-api-key/client/client.gen.ts | 5 +---- .../__snapshots__/3.0.x/security-false/client/client.gen.ts | 5 +---- .../3.0.x/security-http-bearer/client/client.gen.ts | 5 +---- .../__snapshots__/3.0.x/security-oauth2/client/client.gen.ts | 5 +---- .../3.0.x/security-open-id-connect/client/client.gen.ts | 5 +---- .../test/__snapshots__/3.0.x/servers/client/client.gen.ts | 5 +---- .../3.0.x/transformers-all-of/client/client.gen.ts | 5 +---- .../3.0.x/transformers-any-of-null/client/client.gen.ts | 5 +---- .../3.0.x/transformers-array/client/client.gen.ts | 5 +---- .../3.0.x/transforms-read-write/client/client.gen.ts | 5 +---- .../3.1.x/body-response-text-plain/client/client.gen.ts | 5 +---- .../client-fetch/base-url-false/client/client.gen.ts | 5 +---- .../client-fetch/base-url-number/client/client.gen.ts | 5 +---- .../client-fetch/base-url-strict/client/client.gen.ts | 5 +---- .../client-fetch/base-url-string/client/client.gen.ts | 5 +---- .../@hey-api/client-fetch/clean-false/client/client.gen.ts | 5 +---- .../@hey-api/client-fetch/default/client/client.gen.ts | 5 +---- .../client-fetch/sdk-client-optional/client/client.gen.ts | 5 +---- .../client-fetch/sdk-client-required/client/client.gen.ts | 5 +---- .../client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts | 5 +---- .../@hey-api/client-next/base-url-false/client/client.gen.ts | 5 +---- .../client-next/base-url-number/client/client.gen.ts | 5 +---- .../client-next/base-url-strict/client/client.gen.ts | 5 +---- .../client-next/base-url-string/client/client.gen.ts | 5 +---- .../@hey-api/client-next/clean-false/client/client.gen.ts | 5 +---- .../@hey-api/client-next/default/client/client.gen.ts | 5 +---- .../client-next/sdk-client-optional/client/client.gen.ts | 5 +---- .../client-next/sdk-client-required/client/client.gen.ts | 5 +---- .../client-next/tsconfig-nodenext-sdk/client/client.gen.ts | 5 +---- .../test/__snapshots__/3.1.x/headers/client/client.gen.ts | 5 +---- .../3.1.x/internal-name-conflict/client/client.gen.ts | 5 +---- .../__snapshots__/3.1.x/pagination-ref/client/client.gen.ts | 5 +---- .../3.1.x/parameter-explode-false/client/client.gen.ts | 5 +---- .../sdk-nested-classes-instance/client/client.gen.ts | 5 +---- .../client-fetch/sdk-nested-classes/client/client.gen.ts | 5 +---- .../3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts | 5 +---- .../3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts | 5 +---- .../plugins/@hey-api/sdk/throwOnError/client/client.gen.ts | 5 +---- .../transformers/type-format-valibot/client/client.gen.ts | 5 +---- .../transformers/type-format-zod/client/client.gen.ts | 5 +---- .../transforms-read-write-custom-name/client/client.gen.ts | 5 +---- .../transforms-read-write-ignore/client/client.gen.ts | 5 +---- .../3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts | 5 +---- .../plugins/@pinia/colada/group-by-tag/client/client.gen.ts | 5 +---- .../angular-query-experimental/asClass/client/client.gen.ts | 5 +---- .../angular-query-experimental/fetch/client/client.gen.ts | 5 +---- .../name-builder/client/client.gen.ts | 5 +---- .../@tanstack/react-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/react-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/react-query/name-builder/client/client.gen.ts | 5 +---- .../@tanstack/solid-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/solid-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/solid-query/name-builder/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/asClass/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/svelte-query/name-builder/client/client.gen.ts | 5 +---- .../plugins/@tanstack/vue-query/asClass/client/client.gen.ts | 5 +---- .../plugins/@tanstack/vue-query/fetch/client/client.gen.ts | 5 +---- .../@tanstack/vue-query/name-builder/client/client.gen.ts | 5 +---- .../3.1.x/security-api-key/client/client.gen.ts | 5 +---- .../__snapshots__/3.1.x/security-false/client/client.gen.ts | 5 +---- .../3.1.x/security-http-bearer/client/client.gen.ts | 5 +---- .../__snapshots__/3.1.x/security-oauth2/client/client.gen.ts | 5 +---- .../3.1.x/security-open-id-connect/client/client.gen.ts | 5 +---- .../test/__snapshots__/3.1.x/servers/client/client.gen.ts | 5 +---- .../test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts | 5 +---- .../test/__snapshots__/3.1.x/sse-next/client/client.gen.ts | 5 +---- .../3.1.x/transformers-all-of/client/client.gen.ts | 5 +---- .../3.1.x/transformers-any-of-null/client/client.gen.ts | 5 +---- .../3.1.x/transformers-array/client/client.gen.ts | 5 +---- .../3.1.x/transforms-read-write/client/client.gen.ts | 5 +---- .../plugins/@tanstack/meta/client/client.gen.ts | 5 +---- .../test/generated/v3_no_index/client/client.gen.ts.snap | 5 +---- 139 files changed, 139 insertions(+), 556 deletions(-) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts index ca4eebad6..95010de9a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts index 6579f7ab6..d4e51ed2a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts index 06cae5956..8aafb006a 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts @@ -64,10 +64,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap index ff7815f4d..d98de0bc6 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap @@ -65,10 +65,7 @@ export const createClient = (config: Config = {}): Client => { } // remove Content-Type header if body is empty to avoid sending invalid requests - if ( - opts.body === undefined || - (opts.serializedBody !== undefined && opts.serializedBody === '') - ) { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } From bdd77257efff10dbdcf7bf55756ad8b1e5a32d3e Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Tue, 2 Sep 2025 21:57:32 -0400 Subject: [PATCH 10/13] chore(client-fetch,client-nuxt): updates getValidRequestBody to return undefined by default --- .../src/plugins/@hey-api/client-fetch/bundle/client.ts | 3 ++- .../src/plugins/@hey-api/client-next/bundle/client.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts index 3e59d949a..e750a8314 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts @@ -226,7 +226,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index 3cf237b6e..574ca0b57 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -214,7 +214,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = From 10e548828aefb39c8c33d64a9f7acfdd6481e5de Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Tue, 2 Sep 2025 22:05:40 -0400 Subject: [PATCH 11/13] test(client): updates snapshots --- .../2.0.x/body-response-text-plain/client/client.gen.ts | 3 ++- .../test/__snapshots__/2.0.x/form-data/client/client.gen.ts | 3 ++- .../sdk-nested-classes-instance/client/client.gen.ts | 3 ++- .../client-fetch/sdk-nested-classes/client/client.gen.ts | 3 ++- .../2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts | 3 ++- .../2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts | 3 ++- .../plugins/@hey-api/sdk/throwOnError/client/client.gen.ts | 3 ++- .../transformers/type-format-valibot/client/client.gen.ts | 3 ++- .../@hey-api/transformers/type-format-zod/client/client.gen.ts | 3 ++- .../transforms-read-write-custom-name/client/client.gen.ts | 3 ++- .../transforms-read-write-ignore/client/client.gen.ts | 3 ++- .../2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts | 3 ++- .../plugins/@pinia/colada/group-by-tag/client/client.gen.ts | 3 ++- .../angular-query-experimental/asClass/client/client.gen.ts | 3 ++- .../angular-query-experimental/fetch/client/client.gen.ts | 3 ++- .../name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/react-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/react-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/react-query/name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/solid-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/solid-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/solid-query/name-builder/client/client.gen.ts | 3 ++- .../@tanstack/svelte-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/svelte-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/svelte-query/name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/vue-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/vue-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/vue-query/name-builder/client/client.gen.ts | 3 ++- .../__snapshots__/2.0.x/schema-unknown/client/client.gen.ts | 3 ++- .../__snapshots__/2.0.x/security-api-key/client/client.gen.ts | 3 ++- .../__snapshots__/2.0.x/security-basic/client/client.gen.ts | 3 ++- .../__snapshots__/2.0.x/security-false/client/client.gen.ts | 3 ++- .../__snapshots__/2.0.x/security-oauth2/client/client.gen.ts | 3 ++- .../__snapshots__/2.0.x/servers-base-path/client/client.gen.ts | 3 ++- .../test/__snapshots__/2.0.x/servers-host/client/client.gen.ts | 3 ++- .../main/test/__snapshots__/2.0.x/servers/client/client.gen.ts | 3 ++- .../2.0.x/transforms-read-write/client/client.gen.ts | 3 ++- .../3.0.x/body-response-text-plain/client/client.gen.ts | 3 ++- .../3.0.x/internal-name-conflict/client/client.gen.ts | 3 ++- .../3.0.x/parameter-explode-false/client/client.gen.ts | 3 ++- .../sdk-nested-classes-instance/client/client.gen.ts | 3 ++- .../client-fetch/sdk-nested-classes/client/client.gen.ts | 3 ++- .../3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts | 3 ++- .../3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts | 3 ++- .../plugins/@hey-api/sdk/throwOnError/client/client.gen.ts | 3 ++- .../transformers/type-format-valibot/client/client.gen.ts | 3 ++- .../@hey-api/transformers/type-format-zod/client/client.gen.ts | 3 ++- .../transforms-read-write-custom-name/client/client.gen.ts | 3 ++- .../transforms-read-write-ignore/client/client.gen.ts | 3 ++- .../3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts | 3 ++- .../plugins/@pinia/colada/group-by-tag/client/client.gen.ts | 3 ++- .../angular-query-experimental/asClass/client/client.gen.ts | 3 ++- .../angular-query-experimental/fetch/client/client.gen.ts | 3 ++- .../name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/react-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/react-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/react-query/name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/solid-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/solid-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/solid-query/name-builder/client/client.gen.ts | 3 ++- .../@tanstack/svelte-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/svelte-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/svelte-query/name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/vue-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/vue-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/vue-query/name-builder/client/client.gen.ts | 3 ++- .../__snapshots__/3.0.x/security-api-key/client/client.gen.ts | 3 ++- .../__snapshots__/3.0.x/security-false/client/client.gen.ts | 3 ++- .../3.0.x/security-http-bearer/client/client.gen.ts | 3 ++- .../__snapshots__/3.0.x/security-oauth2/client/client.gen.ts | 3 ++- .../3.0.x/security-open-id-connect/client/client.gen.ts | 3 ++- .../main/test/__snapshots__/3.0.x/servers/client/client.gen.ts | 3 ++- .../3.0.x/transformers-all-of/client/client.gen.ts | 3 ++- .../3.0.x/transformers-any-of-null/client/client.gen.ts | 3 ++- .../3.0.x/transformers-array/client/client.gen.ts | 3 ++- .../3.0.x/transforms-read-write/client/client.gen.ts | 3 ++- .../3.1.x/body-response-text-plain/client/client.gen.ts | 3 ++- .../@hey-api/client-fetch/base-url-false/client/client.gen.ts | 3 ++- .../@hey-api/client-fetch/base-url-number/client/client.gen.ts | 3 ++- .../@hey-api/client-fetch/base-url-strict/client/client.gen.ts | 3 ++- .../@hey-api/client-fetch/base-url-string/client/client.gen.ts | 3 ++- .../@hey-api/client-fetch/clean-false/client/client.gen.ts | 3 ++- .../clients/@hey-api/client-fetch/default/client/client.gen.ts | 3 ++- .../client-fetch/sdk-client-optional/client/client.gen.ts | 3 ++- .../client-fetch/sdk-client-required/client/client.gen.ts | 3 ++- .../client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts | 3 ++- .../@hey-api/client-next/base-url-false/client/client.gen.ts | 3 ++- .../@hey-api/client-next/base-url-number/client/client.gen.ts | 3 ++- .../@hey-api/client-next/base-url-strict/client/client.gen.ts | 3 ++- .../@hey-api/client-next/base-url-string/client/client.gen.ts | 3 ++- .../@hey-api/client-next/clean-false/client/client.gen.ts | 3 ++- .../clients/@hey-api/client-next/default/client/client.gen.ts | 3 ++- .../client-next/sdk-client-optional/client/client.gen.ts | 3 ++- .../client-next/sdk-client-required/client/client.gen.ts | 3 ++- .../client-next/tsconfig-nodenext-sdk/client/client.gen.ts | 3 ++- .../main/test/__snapshots__/3.1.x/headers/client/client.gen.ts | 3 ++- .../3.1.x/internal-name-conflict/client/client.gen.ts | 3 ++- .../__snapshots__/3.1.x/pagination-ref/client/client.gen.ts | 3 ++- .../3.1.x/parameter-explode-false/client/client.gen.ts | 3 ++- .../sdk-nested-classes-instance/client/client.gen.ts | 3 ++- .../client-fetch/sdk-nested-classes/client/client.gen.ts | 3 ++- .../3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts | 3 ++- .../3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts | 3 ++- .../plugins/@hey-api/sdk/throwOnError/client/client.gen.ts | 3 ++- .../transformers/type-format-valibot/client/client.gen.ts | 3 ++- .../@hey-api/transformers/type-format-zod/client/client.gen.ts | 3 ++- .../transforms-read-write-custom-name/client/client.gen.ts | 3 ++- .../transforms-read-write-ignore/client/client.gen.ts | 3 ++- .../3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts | 3 ++- .../plugins/@pinia/colada/group-by-tag/client/client.gen.ts | 3 ++- .../angular-query-experimental/asClass/client/client.gen.ts | 3 ++- .../angular-query-experimental/fetch/client/client.gen.ts | 3 ++- .../name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/react-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/react-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/react-query/name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/solid-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/solid-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/solid-query/name-builder/client/client.gen.ts | 3 ++- .../@tanstack/svelte-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/svelte-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/svelte-query/name-builder/client/client.gen.ts | 3 ++- .../plugins/@tanstack/vue-query/asClass/client/client.gen.ts | 3 ++- .../plugins/@tanstack/vue-query/fetch/client/client.gen.ts | 3 ++- .../@tanstack/vue-query/name-builder/client/client.gen.ts | 3 ++- .../__snapshots__/3.1.x/security-api-key/client/client.gen.ts | 3 ++- .../__snapshots__/3.1.x/security-false/client/client.gen.ts | 3 ++- .../3.1.x/security-http-bearer/client/client.gen.ts | 3 ++- .../__snapshots__/3.1.x/security-oauth2/client/client.gen.ts | 3 ++- .../3.1.x/security-open-id-connect/client/client.gen.ts | 3 ++- .../main/test/__snapshots__/3.1.x/servers/client/client.gen.ts | 3 ++- .../test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts | 3 ++- .../test/__snapshots__/3.1.x/sse-next/client/client.gen.ts | 3 ++- .../3.1.x/transformers-all-of/client/client.gen.ts | 3 ++- .../3.1.x/transformers-any-of-null/client/client.gen.ts | 3 ++- .../3.1.x/transformers-array/client/client.gen.ts | 3 ++- .../3.1.x/transforms-read-write/client/client.gen.ts | 3 ++- .../__snapshots__/plugins/@tanstack/meta/client/client.gen.ts | 3 ++- .../test/generated/v3_no_index/client/client.gen.ts.snap | 3 ++- 139 files changed, 278 insertions(+), 139 deletions(-) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/clean-false/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts index 95010de9a..6b56f4523 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/clean-false/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts index d4e51ed2a..f1bc43c02 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts index 8aafb006a..ad44b7fba 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts @@ -216,7 +216,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap index d98de0bc6..329968d82 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap +++ b/packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap @@ -228,7 +228,8 @@ export const createClient = (config: Config = {}): Client => { return options.body; } - return null; + // no body was provided + return undefined; } const makeMethodFn = From b2b6998a1d32718e023615d26d16fa698e94159c Mon Sep 17 00:00:00 2001 From: Fransis Young Date: Thu, 4 Sep 2025 00:32:49 -0400 Subject: [PATCH 12/13] fix(client-angular)!: ensures valid serialized or unserialized body is sent with request BREAKING CHANGE: options.serializedBody is undefined by default, and will only be assigned a value when options.bodySerializer is defined refs: #2553 --- .../3.1.x/sse-angular/client/client.gen.ts | 27 +++++- .../client-angular/__tests__/client.test.ts | 90 ++++++++++++++++++- .../@hey-api/client-angular/bundle/client.ts | 27 +++++- 3 files changed, 135 insertions(+), 9 deletions(-) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts index 93b77ace4..9c5e817f3 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts @@ -69,7 +69,7 @@ export const createClient = (config: Config = {}): Client => { ...options, headers: mergeHeaders(_config.headers, options.headers), httpClient: options.httpClient ?? _config.httpClient, - serializedBody: options.body as any, + serializedBody: undefined, }; if (!opts.httpClient) { @@ -83,12 +83,12 @@ export const createClient = (config: Config = {}): Client => { } } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } @@ -97,7 +97,7 @@ export const createClient = (config: Config = {}): Client => { const req = new HttpRequest( opts.method ?? 'GET', url, - opts.serializedBody || null, + getValidRequestBody(opts), { redirect: 'follow', ...opts, @@ -201,6 +201,25 @@ export const createClient = (config: Config = {}): Client => { } }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return undefined; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/client.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/client.test.ts index 528434d2b..6de439b6b 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/client.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/client.test.ts @@ -1,4 +1,6 @@ -import { describe, expect, it } from 'vitest'; +import type { HttpClient } from '@angular/common/http'; +import { HttpHeaders } from '@angular/common/http'; +import { describe, expect, it, vi } from 'vitest'; import { createClient } from '../bundle/client'; @@ -68,3 +70,89 @@ describe('buildUrl', () => { expect(client.buildUrl(options)).toBe(url); }); }); + +describe('unserialized request body handling', () => { + const client = createClient({ baseUrl: 'https://example.com' }); + + const scenarios = [ + { body: 0 }, + { body: false }, + { body: 'test string' }, + { body: '' }, + ]; + + it.each(scenarios)( + 'handles plain text body with $body value', + async ({ body }) => { + const spy = vi.spyOn(HttpHeaders.prototype, 'delete'); + + const request = client.requestOptions({ + body, + bodySerializer: null, + httpClient: vi.fn() as Partial as HttpClient, + url: '/test', + }); + + expect(request).toMatchObject( + expect.objectContaining({ + body, + }), + ); + + expect(spy).toHaveBeenCalledTimes(0); + }, + ); +}); + +describe('requestOptions serialized request body handling', () => { + const client = createClient({ baseUrl: 'https://example.com' }); + + const scenarios = [ + { + body: '', + expectBodyValue: false, + expectDeleteHeader: 1, + serializedBody: '', + }, + { + body: 0, + expectBodyValue: true, + expectDeleteHeader: 0, + serializedBody: 0, + }, + { + body: false, + expectBodyValue: true, + expectDeleteHeader: 0, + serializedBody: false, + }, + { + body: {}, + expectBodyValue: true, + expectDeleteHeader: 0, + serializedBody: '{"key":"value"}', + }, + ]; + + it.each(scenarios)( + 'handles $serializedBody serializedBody value', + async ({ body, expectBodyValue, expectDeleteHeader, serializedBody }) => { + const spy = vi.spyOn(HttpHeaders.prototype, 'delete'); + + const request = client.requestOptions({ + body, + bodySerializer: () => serializedBody, + httpClient: vi.fn() as Partial as HttpClient, + url: '/test', + }); + + expect(request).toMatchObject( + expect.objectContaining({ + body: expectBodyValue ? serializedBody : null, + }), + ); + + expect(spy).toHaveBeenCalledTimes(expectDeleteHeader); + }, + ); +}); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts index 9a9b6b7b6..6dd96d7ab 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts @@ -67,7 +67,7 @@ export const createClient = (config: Config = {}): Client => { ...options, headers: mergeHeaders(_config.headers, options.headers), httpClient: options.httpClient ?? _config.httpClient, - serializedBody: options.body as any, + serializedBody: undefined, }; if (!opts.httpClient) { @@ -81,12 +81,12 @@ export const createClient = (config: Config = {}): Client => { } } - if (opts.body && opts.bodySerializer) { + if (opts.body !== undefined && opts.bodySerializer) { opts.serializedBody = opts.bodySerializer(opts.body); } // remove Content-Type header if body is empty to avoid sending invalid requests - if (opts.serializedBody === undefined || opts.serializedBody === '') { + if (opts.body === undefined || opts.serializedBody === '') { opts.headers.delete('Content-Type'); } @@ -95,7 +95,7 @@ export const createClient = (config: Config = {}): Client => { const req = new HttpRequest( opts.method ?? 'GET', url, - opts.serializedBody || null, + getValidRequestBody(opts), { redirect: 'follow', ...opts, @@ -199,6 +199,25 @@ export const createClient = (config: Config = {}): Client => { } }; + function getValidRequestBody(options: ResolvedRequestOptions) { + const hasBody = options.body !== undefined; + const isSerializedBody = hasBody && options.bodySerializer; + + if (isSerializedBody) { + const hasSerializedBody = + options.serializedBody !== undefined && options.serializedBody !== ''; + + return hasSerializedBody ? options.serializedBody : null; + } + + // plain/text body + if (hasBody) { + return options.body; + } + + return undefined; + } + const makeMethodFn = (method: Uppercase) => (options: RequestOptions) => request({ ...options, method }); From 074a4598c050036b161a9e04a4b5acae98d97b82 Mon Sep 17 00:00:00 2001 From: Lubos Date: Thu, 4 Sep 2025 23:05:10 +0800 Subject: [PATCH 13/13] Create brave-seahorses-dream.md --- .changeset/brave-seahorses-dream.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/brave-seahorses-dream.md diff --git a/.changeset/brave-seahorses-dream.md b/.changeset/brave-seahorses-dream.md new file mode 100644 index 000000000..aec726579 --- /dev/null +++ b/.changeset/brave-seahorses-dream.md @@ -0,0 +1,5 @@ +--- +"@hey-api/openapi-ts": patch +--- + +fix(client): improve handling of plain text, falsy, and unserialized request bodies