From fba98794ba0adb98c9d4b6ab563b54b13b8f9cf5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:19:15 +0000 Subject: [PATCH 1/7] Initial plan From a0a9b958f83764970e5eca03d94028ae500c8849 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:23:13 +0000 Subject: [PATCH 2/7] Add ResolvedRequestOptions with narrowed headers type to custom-client Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- packages/custom-client/src/types.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/custom-client/src/types.ts b/packages/custom-client/src/types.ts index 8cb353eb81..cac8883e06 100644 --- a/packages/custom-client/src/types.ts +++ b/packages/custom-client/src/types.ts @@ -53,6 +53,18 @@ export interface RequestOptions< url: Url; } +export interface ResolvedRequestOptions< + ThrowOnError extends boolean = boolean, + Url extends string = string, +> extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; + serializedBody?: string; +} + export type RequestResult< TData = unknown, TError = unknown, @@ -96,7 +108,7 @@ type BuildUrlFn = < ) => string; export type Client = CoreClient & { - interceptors: Middleware; + interceptors: Middleware; }; /** From 6087f9a7887b1f23066ed1f43b1c0dd4fc55f7f4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:24:57 +0000 Subject: [PATCH 3/7] Add headers: Headers to ResolvedRequestOptions in all client bundles Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- packages/custom-client/src/client.ts | 4 ++-- .../src/plugins/@hey-api/client-angular/bundle/types.ts | 5 +++++ .../src/plugins/@hey-api/client-fetch/bundle/types.ts | 5 +++++ .../src/plugins/@hey-api/client-ky/bundle/types.ts | 5 +++++ .../src/plugins/@hey-api/client-next/bundle/types.ts | 5 +++++ .../src/plugins/@hey-api/client-ofetch/bundle/types.ts | 5 +++++ 6 files changed, 27 insertions(+), 2 deletions(-) diff --git a/packages/custom-client/src/client.ts b/packages/custom-client/src/client.ts index d0f5b2e49c..ce41702387 100644 --- a/packages/custom-client/src/client.ts +++ b/packages/custom-client/src/client.ts @@ -1,4 +1,4 @@ -import type { Client, Config, RequestOptions } from './types'; +import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types'; import { buildUrl, createConfig, @@ -24,7 +24,7 @@ export const createClient = (config: Config = {}): Client => { return getConfig(); }; - const interceptors = createInterceptors(); + const interceptors = createInterceptors(); // @ts-expect-error const request: Client['request'] = async (options) => { diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/types.ts index 54a9dfe628..e9905be39a 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/types.ts @@ -97,6 +97,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts index f2789cbc52..4fd803261c 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/bundle/types.ts @@ -90,6 +90,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts index 136269181f..f63d63bbe6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ky/bundle/types.ts @@ -122,6 +122,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts index 2a8de33eca..ee3856ff62 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/types.ts @@ -72,6 +72,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts index 38af322af3..30beb390aa 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/bundle/types.ts @@ -154,6 +154,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } From a16e39ed5c47f7f3d708ec0126086e3dcf962ee2 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:34:56 +0000 Subject: [PATCH 4/7] Fix SSE request interceptor headers type in client-next and cleanup unused imports Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- packages/custom-client/src/client.ts | 2 +- .../src/plugins/@hey-api/client-next/bundle/client.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/custom-client/src/client.ts b/packages/custom-client/src/client.ts index ce41702387..4d83b118f5 100644 --- a/packages/custom-client/src/client.ts +++ b/packages/custom-client/src/client.ts @@ -1,4 +1,4 @@ -import type { Client, Config, RequestOptions, ResolvedRequestOptions } from './types'; +import type { Client, Config, ResolvedRequestOptions } from './types'; import { buildUrl, createConfig, diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index 4e76ab03de..783abab7e7 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -65,7 +65,6 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const request: Client['request'] = async (options) => { - // @ts-expect-error const { opts, url } = await beforeRequest(options); for (const fn of interceptors.request.fns) { @@ -207,12 +206,15 @@ export const createClient = (config: Config = {}): Client => { let request = new Request(url, init); const requestInit = { ...init, + // Convert init.headers (HeadersInit) back to Headers for the interceptor + headers: new Headers(init.headers), method: init.method as Config['method'], url, }; for (const fn of interceptors.request.fns) { if (fn) { - await fn(requestInit); + // Type assertion: requestInit has headers: Headers, matching ResolvedRequestOptions + await fn(requestInit as ResolvedRequestOptions); request = new Request(requestInit.url, requestInit); } } From 85bd7f14be97e2bde3b69e653d9e079c8ac060c5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:37:08 +0000 Subject: [PATCH 5/7] Improve type safety of SSE requestInit by explicitly typing required properties Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../src/plugins/@hey-api/client-next/bundle/client.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index 783abab7e7..efc99fe7a4 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -204,7 +204,9 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - const requestInit = { + // Create options for interceptor with properly typed headers + const requestInit: Pick & + RequestInit = { ...init, // Convert init.headers (HeadersInit) back to Headers for the interceptor headers: new Headers(init.headers), @@ -213,7 +215,7 @@ export const createClient = (config: Config = {}): Client => { }; for (const fn of interceptors.request.fns) { if (fn) { - // Type assertion: requestInit has headers: Headers, matching ResolvedRequestOptions + // requestInit structurally matches ResolvedRequestOptions for the interceptor await fn(requestInit as ResolvedRequestOptions); request = new Request(requestInit.url, requestInit); } From f22080e113a58568fad3c9807f80afbe27d8f1f5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Feb 2026 14:39:05 +0000 Subject: [PATCH 6/7] Simplify type annotation in SSE onRequest per code review feedback Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../src/plugins/@hey-api/client-next/bundle/client.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts index efc99fe7a4..117c20f04e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/bundle/client.ts @@ -204,18 +204,17 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); - // Create options for interceptor with properly typed headers - const requestInit: Pick & - RequestInit = { + // Create options for interceptor - convert headers to Headers instance + // to match ResolvedRequestOptions type + const requestInit = { ...init, - // Convert init.headers (HeadersInit) back to Headers for the interceptor headers: new Headers(init.headers), method: init.method as Config['method'], url, }; for (const fn of interceptors.request.fns) { if (fn) { - // requestInit structurally matches ResolvedRequestOptions for the interceptor + // Cast to ResolvedRequestOptions: structurally matches with headers: Headers await fn(requestInit as ResolvedRequestOptions); request = new Request(requestInit.url, requestInit); } From f292aa7a23f788bc2821a7365d4879ba156c7143 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 10 Feb 2026 06:51:03 +0000 Subject: [PATCH 7/7] Regenerate examples to sync with ResolvedRequestOptions type changes Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../src/client/client/types.gen.ts | 5 +++++ examples/openapi-ts-angular/src/client/client/types.gen.ts | 5 +++++ examples/openapi-ts-fastify/src/client/client/types.gen.ts | 5 +++++ examples/openapi-ts-fetch/src/client/client/types.gen.ts | 5 +++++ examples/openapi-ts-ky/src/client/client/types.gen.ts | 5 +++++ examples/openapi-ts-next/src/client/client/client.gen.ts | 7 +++++-- examples/openapi-ts-next/src/client/client/types.gen.ts | 5 +++++ examples/openapi-ts-ofetch/src/client/client/types.gen.ts | 5 +++++ examples/openapi-ts-openai/src/client/client/types.gen.ts | 5 +++++ .../openapi-ts-pinia-colada/src/client/client/types.gen.ts | 5 +++++ .../src/client/client/types.gen.ts | 5 +++++ .../src/client/client/types.gen.ts | 5 +++++ .../src/client/client/types.gen.ts | 5 +++++ .../src/client/client/types.gen.ts | 5 +++++ 14 files changed, 70 insertions(+), 2 deletions(-) diff --git a/examples/openapi-ts-angular-common/src/client/client/types.gen.ts b/examples/openapi-ts-angular-common/src/client/client/types.gen.ts index 18bc780efb..76668ecc1d 100644 --- a/examples/openapi-ts-angular-common/src/client/client/types.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/client/types.gen.ts @@ -96,6 +96,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-angular/src/client/client/types.gen.ts b/examples/openapi-ts-angular/src/client/client/types.gen.ts index 18bc780efb..76668ecc1d 100644 --- a/examples/openapi-ts-angular/src/client/client/types.gen.ts +++ b/examples/openapi-ts-angular/src/client/client/types.gen.ts @@ -96,6 +96,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-fastify/src/client/client/types.gen.ts b/examples/openapi-ts-fastify/src/client/client/types.gen.ts index 61a8dffa32..79041f6378 100644 --- a/examples/openapi-ts-fastify/src/client/client/types.gen.ts +++ b/examples/openapi-ts-fastify/src/client/client/types.gen.ts @@ -89,6 +89,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-fetch/src/client/client/types.gen.ts b/examples/openapi-ts-fetch/src/client/client/types.gen.ts index 61a8dffa32..79041f6378 100644 --- a/examples/openapi-ts-fetch/src/client/client/types.gen.ts +++ b/examples/openapi-ts-fetch/src/client/client/types.gen.ts @@ -89,6 +89,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-ky/src/client/client/types.gen.ts b/examples/openapi-ts-ky/src/client/client/types.gen.ts index 5b83a0ab00..4d66bba196 100644 --- a/examples/openapi-ts-ky/src/client/client/types.gen.ts +++ b/examples/openapi-ts-ky/src/client/client/types.gen.ts @@ -121,6 +121,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-next/src/client/client/client.gen.ts b/examples/openapi-ts-next/src/client/client/client.gen.ts index 45519b96b9..67f64c401e 100644 --- a/examples/openapi-ts-next/src/client/client/client.gen.ts +++ b/examples/openapi-ts-next/src/client/client/client.gen.ts @@ -67,7 +67,6 @@ export const createClient = (config: Config = {}): Client => { // @ts-expect-error const request: Client['request'] = async (options) => { - // @ts-expect-error const { opts, url } = await beforeRequest(options); for (const fn of interceptors.request.fns) { @@ -207,14 +206,18 @@ export const createClient = (config: Config = {}): Client => { method, onRequest: async (url, init) => { let request = new Request(url, init); + // Create options for interceptor - convert headers to Headers instance + // to match ResolvedRequestOptions type const requestInit = { ...init, + headers: new Headers(init.headers), method: init.method as Config['method'], url, }; for (const fn of interceptors.request.fns) { if (fn) { - await fn(requestInit); + // Cast to ResolvedRequestOptions: structurally matches with headers: Headers + await fn(requestInit as ResolvedRequestOptions); request = new Request(requestInit.url, requestInit); } } diff --git a/examples/openapi-ts-next/src/client/client/types.gen.ts b/examples/openapi-ts-next/src/client/client/types.gen.ts index 6dcf29dca3..5c510c6459 100644 --- a/examples/openapi-ts-next/src/client/client/types.gen.ts +++ b/examples/openapi-ts-next/src/client/client/types.gen.ts @@ -71,6 +71,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-ofetch/src/client/client/types.gen.ts b/examples/openapi-ts-ofetch/src/client/client/types.gen.ts index a193bd1d75..6020d0a9d1 100644 --- a/examples/openapi-ts-ofetch/src/client/client/types.gen.ts +++ b/examples/openapi-ts-ofetch/src/client/client/types.gen.ts @@ -153,6 +153,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-openai/src/client/client/types.gen.ts b/examples/openapi-ts-openai/src/client/client/types.gen.ts index cb6d0d54a0..44b69e041f 100644 --- a/examples/openapi-ts-openai/src/client/client/types.gen.ts +++ b/examples/openapi-ts-openai/src/client/client/types.gen.ts @@ -92,6 +92,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-pinia-colada/src/client/client/types.gen.ts b/examples/openapi-ts-pinia-colada/src/client/client/types.gen.ts index 61a8dffa32..79041f6378 100644 --- a/examples/openapi-ts-pinia-colada/src/client/client/types.gen.ts +++ b/examples/openapi-ts-pinia-colada/src/client/client/types.gen.ts @@ -89,6 +89,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/types.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/types.gen.ts index 18bc780efb..76668ecc1d 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/types.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/types.gen.ts @@ -96,6 +96,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-tanstack-react-query/src/client/client/types.gen.ts b/examples/openapi-ts-tanstack-react-query/src/client/client/types.gen.ts index 61a8dffa32..79041f6378 100644 --- a/examples/openapi-ts-tanstack-react-query/src/client/client/types.gen.ts +++ b/examples/openapi-ts-tanstack-react-query/src/client/client/types.gen.ts @@ -89,6 +89,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-tanstack-svelte-query/src/client/client/types.gen.ts b/examples/openapi-ts-tanstack-svelte-query/src/client/client/types.gen.ts index 61a8dffa32..79041f6378 100644 --- a/examples/openapi-ts-tanstack-svelte-query/src/client/client/types.gen.ts +++ b/examples/openapi-ts-tanstack-svelte-query/src/client/client/types.gen.ts @@ -89,6 +89,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; } diff --git a/examples/openapi-ts-tanstack-vue-query/src/client/client/types.gen.ts b/examples/openapi-ts-tanstack-vue-query/src/client/client/types.gen.ts index 61a8dffa32..79041f6378 100644 --- a/examples/openapi-ts-tanstack-vue-query/src/client/client/types.gen.ts +++ b/examples/openapi-ts-tanstack-vue-query/src/client/client/types.gen.ts @@ -89,6 +89,11 @@ export interface ResolvedRequestOptions< ThrowOnError extends boolean = boolean, Url extends string = string, > extends RequestOptions { + /** + * Headers object after merging config and request headers. + * Always a Headers instance in request interceptors. + */ + headers: Headers; serializedBody?: string; }