fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #2542 from hey-api/fix/sse-fetch

authored by

Lubos and committed by
GitHub
20322224 d3923a82

+6502 -362
+5
.changeset/cyan-crabs-vanish.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix(client): pass fetch option to sse client
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/body-response-text-plain/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/form-data/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/schema-unknown/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-api-key/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-basic/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/security-oauth2/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-base-path/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers-host/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/servers/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/transforms-read-write/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/body-response-text-plain/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/content-types/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/internal-name-conflict/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/parameter-explode-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-api-key/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-http-bearer/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-oauth2/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/security-open-id-connect/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/servers/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-all-of/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-any-of-null/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transformers-array/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/transforms-read-write/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/body-response-text-plain/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-number/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-strict/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/base-url-string/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/default/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-optional/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/sdk-client-required/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-axios/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-number/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-strict/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/base-url-string/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/default/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-optional/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/sdk-client-required/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-fetch/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-number/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-strict/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/base-url-string/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/default/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-optional/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/sdk-client-required/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-next/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-number/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-strict/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/base-url-string/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/default/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-optional/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/sdk-client-required/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-nuxt/tsconfig-nodenext-sdk/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/content-types/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/headers/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/internal-name-conflict/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/pagination-ref/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false-axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/parameter-explode-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes-instance/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/client-fetch/sdk-nested-classes/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/default/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/instance/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/sdk/throwOnError/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-valibot/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/transformers/type-format-zod/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-custom-name/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@hey-api/typescript/transforms-read-write-ignore/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@pinia/colada/group-by-tag/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/angular-query-experimental/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/react-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/solid-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/svelte-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/asClass/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@tanstack/vue-query/name-builder/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-api-key/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-false/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-http-bearer/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-oauth2/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/security-open-id-connect/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/servers/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-axios/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-fetch/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+15
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/client/client.gen.ts
··· 210 210 body: opts.body as BodyInit | null | undefined, 211 211 headers: opts.headers as unknown as Record<string, string>, 212 212 method, 213 + onRequest: async (url, init) => { 214 + let request = new Request(url, init); 215 + const requestInit = { 216 + ...init, 217 + method: init.method as Config['method'], 218 + url, 219 + }; 220 + for (const fn of interceptors.request._fns) { 221 + if (fn) { 222 + await fn(requestInit); 223 + request = new Request(requestInit.url, requestInit); 224 + } 225 + } 226 + return request; 227 + }, 213 228 url, 214 229 }); 215 230 };
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-next/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/client/client.gen.ts
··· 194 194 ...unwrapRefs(opts), 195 195 body: opts.body as BodyInit | null | undefined, 196 196 method, 197 + onRequest: undefined, 197 198 signal: unwrapRefs(opts.signal) as AbortSignal, 198 199 url, 199 200 });
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-nuxt/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-all-of/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-any-of-null/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transformers-array/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/transforms-read-write/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/client.gen.ts
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/client/types.gen.ts
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/plugins/@tanstack/meta/core/serverSentEvents.gen.ts
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+9
packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/client.gen.ts.snap
··· 224 224 body: opts.body as BodyInit | null | undefined, 225 225 headers: opts.headers as unknown as Record<string, string>, 226 226 method, 227 + onRequest: async (url, init) => { 228 + let request = new Request(url, init); 229 + for (const fn of interceptors.request._fns) { 230 + if (fn) { 231 + request = await fn(request, opts); 232 + } 233 + } 234 + return request; 235 + }, 227 236 url, 228 237 }); 229 238 };
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/client/types.gen.ts.snap
··· 26 26 * 27 27 * @default globalThis.fetch 28 28 */ 29 - fetch?: (request: Request) => ReturnType<typeof fetch>; 29 + fetch?: typeof fetch; 30 30 /** 31 31 * Please don't use the Fetch client for Next.js applications. The `next` 32 32 * options won't have any effect.
+28 -1
packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v3_no_index/core/serverSentEvents.gen.ts.snap
··· 8 8 > & 9 9 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 10 10 /** 11 + * Fetch API implementation. You can use this option to provide a custom 12 + * fetch instance. 13 + * 14 + * @default globalThis.fetch 15 + */ 16 + fetch?: typeof fetch; 17 + /** 18 + * Implementing clients can call request interceptors inside this hook. 19 + */ 20 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 21 + /** 11 22 * Callback invoked when a network or parsing error occurs during streaming. 12 23 * 13 24 * This option applies only if the endpoint returns a stream of events. ··· 24 35 * @returns Nothing (void). 25 36 */ 26 37 onSseEvent?: (event: StreamEvent<TData>) => void; 38 + serializedBody?: RequestInit['body']; 27 39 /** 28 40 * Default retry delay in milliseconds. 29 41 * ··· 75 87 }; 76 88 77 89 export const createSseClient = <TData = unknown>({ 90 + onRequest, 78 91 onSseError, 79 92 onSseEvent, 80 93 responseTransformer, ··· 112 125 } 113 126 114 127 try { 115 - const response = await fetch(url, { ...options, headers, signal }); 128 + const requestInit: RequestInit = { 129 + redirect: 'follow', 130 + ...options, 131 + body: options.serializedBody, 132 + headers, 133 + signal, 134 + }; 135 + let request = new Request(url, requestInit); 136 + if (onRequest) { 137 + request = await onRequest(url, requestInit); 138 + } 139 + // fetch must be assigned here, otherwise it would throw the error: 140 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 141 + const _fetch = options.fetch ?? globalThis.fetch; 142 + const response = await _fetch(request); 116 143 117 144 if (!response.ok) 118 145 throw new Error(
+2 -2
packages/openapi-ts-tests/main/test/openapi-ts.config.ts
··· 36 36 '3.1.x', 37 37 // 'invalid', 38 38 // 'openai.yaml', 39 - 'full.yaml', 40 - // 'opencode.yaml', 39 + // 'full.yaml', 40 + 'opencode.yaml', 41 41 // 'zoom-video-sdk.json', 42 42 ), 43 43 // https://registry.scalar.com/@lubos-heyapi-dev-team/apis/demo-api-scalar-galaxy/latest?format=json
+100 -48
packages/openapi-ts/src/plugins/@hey-api/client-core/__tests__/serverSentEvents.test.ts
··· 16 16 }); 17 17 } 18 18 19 + function toRequest(input: RequestInfo, init?: RequestInit): Request { 20 + if (input instanceof Request) { 21 + const url = input.url.startsWith('http') 22 + ? input.url 23 + : `http://localhost${input.url}`; 24 + return new Request(url, input); 25 + } 26 + const url = input.startsWith('http') ? input : `http://localhost${input}`; 27 + return new Request(url, init); 28 + } 29 + 19 30 describe('createSseClient', () => { 20 31 let fetchMock: any; 21 32 ··· 35 46 }); 36 47 37 48 const onEvent = vi.fn(); 38 - const { stream } = createSseClient({ onSseEvent: onEvent, url: '/sse' }); 49 + const { stream } = createSseClient({ 50 + onSseEvent: onEvent, 51 + url: 'http://localhost/sse', 52 + }); 39 53 40 54 const result: any[] = []; 41 55 for await (const ev of stream) result.push(ev); ··· 55 69 ok: true, 56 70 }); 57 71 58 - const { stream } = createSseClient({ url: '/sse' }); 72 + const { stream } = createSseClient({ url: 'http://localhost/sse' }); 59 73 const result: any[] = []; 60 74 for await (const ev of stream) result.push(ev); 61 75 ··· 76 90 onSseError: onError, 77 91 signal: controller.signal, 78 92 sseDefaultRetryDelay: 0, 79 - url: '/sse', 93 + url: 'http://localhost/sse', 80 94 }); 81 95 82 96 const iter = stream[Symbol.asyncIterator](); ··· 97 111 }); 98 112 99 113 const onEvent = vi.fn(); 100 - const { stream } = createSseClient({ onSseEvent: onEvent, url: '/sse' }); 114 + const { stream } = createSseClient({ 115 + onSseEvent: onEvent, 116 + url: 'http://localhost/sse', 117 + }); 101 118 102 119 const iter = stream[Symbol.asyncIterator](); 103 120 await iter.next(); ··· 117 134 ok: true, 118 135 }); 119 136 120 - const { stream } = createSseClient({ url: '/sse' }); 137 + const { stream } = createSseClient({ url: 'http://localhost/sse' }); 121 138 const result: any[] = []; 122 139 for await (const ev of stream) result.push(ev); 123 140 expect(result).toEqual([1, 2, 3]); ··· 129 146 ok: true, 130 147 }); 131 148 132 - const { stream } = createSseClient({ url: '/sse' }); 149 + const { stream } = createSseClient({ url: 'http://localhost/sse' }); 133 150 const result: any[] = []; 134 151 for await (const ev of stream) result.push(ev); 135 152 expect(result).toEqual(['partial']); 136 153 }); 137 154 138 155 it('sets Last-Event-ID header on reconnect', async () => { 139 - let headersSeen: Headers | undefined; 140 - fetchMock.mockImplementation(async (_url: any, opts: any) => { 141 - headersSeen = opts?.headers.get('Last-Event-ID'); 142 - return { 143 - body: makeStream(['data: a\n\n']), 144 - ok: true, 145 - }; 146 - }); 156 + let headersSeen: string | null | undefined; 157 + fetchMock.mockImplementation( 158 + async (input: RequestInfo, init?: RequestInit) => { 159 + const req = toRequest(input, init); 160 + headersSeen = req.headers.get('Last-Event-ID'); 161 + return { 162 + body: makeStream(['data: a\n\n']), 163 + ok: true, 164 + }; 165 + }, 166 + ); 147 167 148 168 const onEvent = vi.fn(); 149 - const { stream } = createSseClient({ onSseEvent: onEvent, url: '/sse' }); 169 + const { stream } = createSseClient({ 170 + onSseEvent: onEvent, 171 + url: 'http://localhost/sse', 172 + }); 150 173 151 174 const iter = stream[Symbol.asyncIterator](); 152 175 await iter.next(); 153 176 await iter.return?.(); 154 177 155 178 // simulate next fetch after reconnect 156 - await fetchMock('/sse', { headers: new Headers({ 'Last-Event-ID': '1' }) }); 179 + await fetchMock('http://localhost/sse', { 180 + headers: new Headers({ 'Last-Event-ID': '1' }), 181 + }); 157 182 expect(headersSeen).toBe('1'); 158 183 }); 159 184 ··· 166 191 const controller = new AbortController(); 167 192 const { stream } = createSseClient({ 168 193 signal: controller.signal, 169 - url: '/sse', 194 + url: 'http://localhost/sse', 170 195 }); 171 196 172 197 const iter = stream[Symbol.asyncIterator](); ··· 188 213 ok: true, 189 214 }); 190 215 191 - const { stream } = createSseClient({ url: '/sse' }); 216 + const { stream } = createSseClient({ url: 'http://localhost/sse' }); 192 217 const result: any[] = []; 193 218 for await (const ev of stream) result.push(ev); 194 219 expect(result).toEqual([{ foo: 1 }, 'bar', { baz: 2 }]); 195 220 }); 196 221 197 222 it('passes custom headers', async () => { 198 - let headersSeen: Headers | undefined; 199 - fetchMock.mockImplementation(async (_url: any, opts: any) => { 200 - headersSeen = opts.headers.get('X-Custom'); 201 - return { body: makeStream([]), ok: true }; 202 - }); 223 + let headersSeen: string | null | undefined; 224 + fetchMock.mockImplementation( 225 + async (input: RequestInfo, init?: RequestInit) => { 226 + const req = toRequest(input, init); 227 + headersSeen = req.headers.get('X-Custom'); 228 + return { 229 + body: makeStream([]), 230 + ok: true, 231 + }; 232 + }, 233 + ); 203 234 204 235 const { stream } = createSseClient({ 205 236 headers: { 'X-Custom': 'abc' }, 206 - url: '/sse', 237 + url: 'http://localhost/sse', 207 238 }); 208 239 209 240 const iter = stream[Symbol.asyncIterator](); ··· 219 250 ok: true, 220 251 }); 221 252 222 - const { stream } = createSseClient({ url: '/sse' }); 253 + const { stream } = createSseClient({ url: 'http://localhost/sse' }); 223 254 const result: any[] = []; 224 255 for await (const ev of stream) result.push(ev); 225 256 expect(result).toEqual([{ foo: 'bar' }]); ··· 227 258 228 259 it('handles empty stream', async () => { 229 260 fetchMock.mockResolvedValue({ body: makeStream([]), ok: true }); 230 - const { stream } = createSseClient({ url: '/sse' }); 261 + const { stream } = createSseClient({ url: 'http://localhost/sse' }); 231 262 const iter = stream[Symbol.asyncIterator](); 232 263 const first = await iter.next(); 233 264 expect(first).toEqual({ done: true, value: undefined }); ··· 238 269 fetchMock.mockImplementation(async () => { 239 270 attempt++; 240 271 if (attempt < 2) throw new Error('fail'); 241 - return { body: makeStream(['data: ok\n\n']), ok: true }; 272 + return { 273 + body: makeStream(['data: ok\n\n']), 274 + ok: true, 275 + }; 242 276 }); 243 277 244 278 const onError = vi.fn(); 245 279 const { stream } = createSseClient({ 246 280 onSseError: onError, 247 281 sseDefaultRetryDelay: 0, 248 - url: '/sse', 282 + url: 'http://localhost/sse', 249 283 }); 250 284 251 285 const result: any[] = []; ··· 262 296 }); 263 297 264 298 const onEvent = vi.fn(); 265 - const { stream } = createSseClient({ onSseEvent: onEvent, url: '/sse' }); 299 + const { stream } = createSseClient({ 300 + onSseEvent: onEvent, 301 + url: 'http://localhost/sse', 302 + }); 266 303 const iter = stream[Symbol.asyncIterator](); 267 304 const ev = await iter.next(); 268 305 expect(ev.value).toBe('x'); ··· 276 313 }); 277 314 278 315 const onEvent = vi.fn(); 279 - const { stream } = createSseClient({ onSseEvent: onEvent, url: '/sse' }); 316 + const { stream } = createSseClient({ 317 + onSseEvent: onEvent, 318 + url: 'http://localhost/sse', 319 + }); 280 320 const iter = stream[Symbol.asyncIterator](); 281 321 const ev = await iter.next(); 282 322 expect(ev.done).toBe(true); ··· 299 339 const { stream } = createSseClient({ 300 340 onSseError: onError, 301 341 onSseEvent: onEvent, 302 - url: '/sse', 342 + url: 'http://localhost/sse', 303 343 }); 304 344 const iter = stream[Symbol.asyncIterator](); 305 345 const ev = await iter.next(); ··· 316 356 const controller = new AbortController(); 317 357 const { stream } = createSseClient({ 318 358 signal: controller.signal, 319 - url: '/sse', 359 + url: 'http://localhost/sse', 320 360 }); 321 361 const iter = stream[Symbol.asyncIterator](); 322 362 await iter.next(); ··· 343 383 controller.abort(); 344 384 const { stream } = createSseClient({ 345 385 signal: controller.signal, 346 - url: '/sse', 386 + url: 'http://localhost/sse', 347 387 }); 348 388 const iter = stream[Symbol.asyncIterator](); 349 389 const ev = await iter.next(); ··· 352 392 353 393 it('respects custom HTTP method', async () => { 354 394 let methodSeen: string | undefined; 355 - fetchMock.mockImplementation(async (_url: any, opts: any) => { 356 - methodSeen = opts.method; 357 - return { body: makeStream(['data: ok\n\n']), ok: true }; 358 - }); 395 + fetchMock.mockImplementation( 396 + async (input: RequestInfo, init?: RequestInit) => { 397 + const req = toRequest(input, init); 398 + methodSeen = req.method; 399 + return { 400 + body: makeStream(['data: ok\n\n']), 401 + ok: true, 402 + }; 403 + }, 404 + ); 359 405 360 - const { stream } = createSseClient({ method: 'POST', url: '/sse' }); 406 + const { stream } = createSseClient({ 407 + method: 'POST', 408 + url: 'http://localhost/sse', 409 + }); 361 410 const iter = stream[Symbol.asyncIterator](); 362 411 await iter.next(); 363 412 await iter.return?.(); ··· 374 423 const controller = new AbortController(); 375 424 const { stream } = createSseClient({ 376 425 signal: controller.signal, 377 - url: '/sse', 426 + url: 'http://localhost/sse', 378 427 }); 379 428 380 429 const iter = stream[Symbol.asyncIterator](); ··· 397 446 onSseEvent: (ev) => { 398 447 lastEventId = ev.id; 399 448 }, 400 - url: '/sse', 449 + url: 'http://localhost/sse', 401 450 }); 402 451 403 452 stream[Symbol.asyncIterator](); ··· 422 471 onSseError: onError, 423 472 sseDefaultRetryDelay: 0, 424 473 sseMaxRetryAttempts: 2, 425 - url: '/sse', 474 + url: 'http://localhost/sse', 426 475 }); 427 476 428 477 const iter = stream[Symbol.asyncIterator](); ··· 439 488 fetchMock.mockImplementation(() => { 440 489 attempt++; 441 490 if (attempt < 3) throw new Error('fail'); 442 - return Promise.resolve({ body: makeStream(['data: ok\n\n']), ok: true }); 491 + return Promise.resolve({ 492 + body: makeStream(['data: ok\n\n']), 493 + ok: true, 494 + }); 443 495 }); 444 496 445 497 const onError = vi.fn(); ··· 448 500 sseDefaultRetryDelay: 10, 449 501 // Inject a fake sleep that resolves instantly 450 502 sseSleepFn: async () => {}, 451 - url: '/sse', 503 + url: 'http://localhost/sse', 452 504 }); 453 505 454 506 const iter = stream[Symbol.asyncIterator](); ··· 471 523 const { stream } = createSseClient({ 472 524 onSseError: onError, 473 525 sseMaxRetryAttempts: 0, 474 - url: '/sse', 526 + url: 'http://localhost/sse', 475 527 }); 476 528 477 529 const iter = stream[Symbol.asyncIterator](); ··· 494 546 495 547 const { stream } = createSseClient({ 496 548 responseValidator: validator, 497 - url: '/sse', 549 + url: 'http://localhost/sse', 498 550 }); 499 551 500 552 const result: any[] = []; ··· 516 568 517 569 const { stream } = createSseClient({ 518 570 responseTransformer: transformer, 519 - url: '/sse', 571 + url: 'http://localhost/sse', 520 572 }); 521 573 522 574 const result: any[] = []; ··· 546 598 responseValidator: validator, 547 599 sseDefaultRetryDelay: 0, 548 600 sseMaxRetryAttempts: 1, 549 - url: '/sse', 601 + url: 'http://localhost/sse', 550 602 }); 551 603 552 604 const iter = stream[Symbol.asyncIterator](); ··· 567 619 const { stream } = createSseClient({ 568 620 responseTransformer: transformer, 569 621 responseValidator: validator, 570 - url: '/sse', 622 + url: 'http://localhost/sse', 571 623 }); 572 624 573 625 const result: any[] = [];
+28 -1
packages/openapi-ts/src/plugins/@hey-api/client-core/bundle/serverSentEvents.ts
··· 6 6 > & 7 7 Pick<Config, 'method' | 'responseTransformer' | 'responseValidator'> & { 8 8 /** 9 + * Fetch API implementation. You can use this option to provide a custom 10 + * fetch instance. 11 + * 12 + * @default globalThis.fetch 13 + */ 14 + fetch?: typeof fetch; 15 + /** 16 + * Implementing clients can call request interceptors inside this hook. 17 + */ 18 + onRequest?: (url: string, init: RequestInit) => Promise<Request>; 19 + /** 9 20 * Callback invoked when a network or parsing error occurs during streaming. 10 21 * 11 22 * This option applies only if the endpoint returns a stream of events. ··· 22 33 * @returns Nothing (void). 23 34 */ 24 35 onSseEvent?: (event: StreamEvent<TData>) => void; 36 + serializedBody?: RequestInit['body']; 25 37 /** 26 38 * Default retry delay in milliseconds. 27 39 * ··· 73 85 }; 74 86 75 87 export const createSseClient = <TData = unknown>({ 88 + onRequest, 76 89 onSseError, 77 90 onSseEvent, 78 91 responseTransformer, ··· 110 123 } 111 124 112 125 try { 113 - const response = await fetch(url, { ...options, headers, signal }); 126 + const requestInit: RequestInit = { 127 + redirect: 'follow', 128 + ...options, 129 + body: options.serializedBody, 130 + headers, 131 + signal, 132 + }; 133 + let request = new Request(url, requestInit); 134 + if (onRequest) { 135 + request = await onRequest(url, requestInit); 136 + } 137 + // fetch must be assigned here, otherwise it would throw the error: 138 + // TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation 139 + const _fetch = options.fetch ?? globalThis.fetch; 140 + const response = await _fetch(request); 114 141 115 142 if (!response.ok) 116 143 throw new Error(
+11 -7
packages/openapi-ts/src/plugins/@hey-api/client-fetch/__tests__/client.test.ts
··· 2 2 3 3 import { createClient } from '../bundle/client'; 4 4 5 + type MockFetch = ((...args: any[]) => any) & { 6 + preconnect?: any; 7 + }; 8 + 5 9 describe('buildUrl', () => { 6 10 const client = createClient(); 7 11 ··· 81 85 status: 200, 82 86 }); 83 87 84 - const mockFetch = vi.fn().mockResolvedValue(mockResponse); 88 + const mockFetch: MockFetch = vi.fn().mockResolvedValue(mockResponse); 85 89 86 90 const result = await client.request({ 87 91 fetch: mockFetch, ··· 101 105 status: 200, 102 106 }); 103 107 104 - const mockFetch = vi.fn().mockResolvedValue(mockResponse); 108 + const mockFetch: MockFetch = vi.fn().mockResolvedValue(mockResponse); 105 109 106 110 const result = await client.request({ 107 111 fetch: mockFetch, ··· 123 127 status: 200, 124 128 }); 125 129 126 - const mockFetch = vi.fn().mockResolvedValue(mockResponse); 130 + const mockFetch: MockFetch = vi.fn().mockResolvedValue(mockResponse); 127 131 128 132 const result = await client.request({ 129 133 fetch: mockFetch, ··· 143 147 status: 200, 144 148 }); 145 149 146 - const mockFetch = vi.fn().mockResolvedValue(mockResponse); 150 + const mockFetch: MockFetch = vi.fn().mockResolvedValue(mockResponse); 147 151 148 152 const result = await client.request({ 149 153 fetch: mockFetch, ··· 163 167 status: 200, 164 168 }); 165 169 166 - const mockFetch = vi.fn().mockResolvedValue(mockResponse); 170 + const mockFetch: MockFetch = vi.fn().mockResolvedValue(mockResponse); 167 171 168 172 const result = await client.request({ 169 173 fetch: mockFetch, ··· 184 188 status: 200, 185 189 }); 186 190 187 - const mockFetch = vi.fn().mockResolvedValue(mockResponse); 191 + const mockFetch: MockFetch = vi.fn().mockResolvedValue(mockResponse); 188 192 189 193 const result = await client.request({ 190 194 fetch: mockFetch, ··· 205 209 status: 200, 206 210 }); 207 211 208 - const mockFetch = vi.fn().mockResolvedValue(mockResponse); 212 + const mockFetch: MockFetch = vi.fn().mockResolvedValue(mockResponse); 209 213 210 214 const result = await client.request({ 211 215 fetch: mockFetch,
+9
packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/client.ts
··· 222 222 body: opts.body as BodyInit | null | undefined, 223 223 headers: opts.headers as unknown as Record<string, string>, 224 224 method, 225 + onRequest: async (url, init) => { 226 + let request = new Request(url, init); 227 + for (const fn of interceptors.request._fns) { 228 + if (fn) { 229 + request = await fn(request, opts); 230 + } 231 + } 232 + return request; 233 + }, 225 234 url, 226 235 }); 227 236 };
+1 -1
packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts
··· 24 24 * 25 25 * @default globalThis.fetch 26 26 */ 27 - fetch?: (request: Request) => ReturnType<typeof fetch>; 27 + fetch?: typeof fetch; 28 28 /** 29 29 * Please don't use the Fetch client for Next.js applications. The `next` 30 30 * options won't have any effect.
+15
packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts
··· 208 208 body: opts.body as BodyInit | null | undefined, 209 209 headers: opts.headers as unknown as Record<string, string>, 210 210 method, 211 + onRequest: async (url, init) => { 212 + let request = new Request(url, init); 213 + const requestInit = { 214 + ...init, 215 + method: init.method as Config['method'], 216 + url, 217 + }; 218 + for (const fn of interceptors.request._fns) { 219 + if (fn) { 220 + await fn(requestInit); 221 + request = new Request(requestInit.url, requestInit); 222 + } 223 + } 224 + return request; 225 + }, 211 226 url, 212 227 }); 213 228 };
+1
packages/openapi-ts/src/plugins/@hey-api/client-nuxt/bundle/client.ts
··· 192 192 ...unwrapRefs(opts), 193 193 body: opts.body as BodyInit | null | undefined, 194 194 method, 195 + onRequest: undefined, 195 196 signal: unwrapRefs(opts.signal) as AbortSignal, 196 197 url, 197 198 });
+6
pnpm-workspace.yaml
··· 3 3 - examples/**/* 4 4 - packages/**/* 5 5 6 + onlyBuiltDependencies: 7 + - esbuild 8 + - lmdb 9 + - sharp 10 + - unrs-resolver 11 + 6 12 patchedDependencies: 7 13 vitepress: patches/vitepress.patch