From 97d5e1097a75294af9e9818a3c3e9d8eb199e2a6 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 11:59:19 -0600 Subject: [PATCH 01/10] Fix how headers are handled in @hey-api/client-angular --- .../@hey-api/client-angular/bundle/client.ts | 14 ++++++++++---- .../@hey-api/client-angular/bundle/utils.ts | 3 ++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts index 91136abca8..ccd8c6a5ff 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts @@ -85,6 +85,10 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = (opts: any) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -92,7 +96,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -103,10 +107,10 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ + opts.headers = await setAuthParams({ ...opts, security: opts.security, }); @@ -116,6 +120,8 @@ export const createClient = (config: Config = {}): Client => { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -237,7 +243,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts index d8f2897334..8d5592b3c7 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts @@ -211,8 +211,9 @@ export const setAuthParams = async ( break; } - return; + return options.headers; } + return options.headers; }; export const buildUrl: Client['buildUrl'] = (options) => { From 8db4b2d17f752d0fe940f3e35c3618bf6735a479 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 14:08:51 -0600 Subject: [PATCH 02/10] Add changeset for change to the angular client --- .changeset/hot-baboons-carry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/hot-baboons-carry.md diff --git a/.changeset/hot-baboons-carry.md b/.changeset/hot-baboons-carry.md new file mode 100644 index 0000000000..63b77ab263 --- /dev/null +++ b/.changeset/hot-baboons-carry.md @@ -0,0 +1,5 @@ +--- +"@hey-api/openapi-ts": minor +--- + +Fix how headers are handled in @hey-api/client-angular#3860 From 2704bcc07c82c960a855df2388fa18e65ef3fce3 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 14:30:44 -0600 Subject: [PATCH 03/10] Fix parameter type on finalizeRequest function --- .../plugins/@hey-api/client-angular/bundle/client.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts index ccd8c6a5ff..ccc2d0092c 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts @@ -1,4 +1,4 @@ -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -88,7 +88,15 @@ export const createClient = (config: Config = {}): Client => { return opts; }; - const finalizeRequest = (opts: any) => { + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { From 6e48019c9844c078c4b9064c22d785be72f4ad7c Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 14:52:33 -0600 Subject: [PATCH 04/10] Fix input types on setAuthParams to be able to take references --- .../@hey-api/client-angular/bundle/client.ts | 5 +---- .../plugins/@hey-api/client-angular/bundle/utils.ts | 13 ++++++------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts index ccc2d0092c..7f0bdf3ffa 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/client.ts @@ -118,10 +118,7 @@ export const createClient = (config: Config = {}): Client => { const opts = requestOptions(options); if (opts.security) { - opts.headers = await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts index 8d5592b3c7..caa41d6a60 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts @@ -181,12 +181,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -211,9 +211,8 @@ export const setAuthParams = async ( break; } - return options.headers; + return; } - return options.headers; }; export const buildUrl: Client['buildUrl'] = (options) => { From 144be7dcd3a15f7d6a49ba43e6cde009447841bd Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:00:52 -0600 Subject: [PATCH 05/10] Regenerate examples after fixing angular client --- .../src/client/client/client.gen.ts | 27 +++++++++++++------ .../src/client/client/utils.gen.ts | 10 +++---- .../src/client/client/client.gen.ts | 27 +++++++++++++------ .../src/client/client/utils.gen.ts | 10 +++---- .../src/client/client/client.gen.ts | 27 +++++++++++++------ .../src/client/client/utils.gen.ts | 10 +++---- 6 files changed, 72 insertions(+), 39 deletions(-) diff --git a/examples/openapi-ts-angular-common/src/client/client/client.gen.ts b/examples/openapi-ts-angular-common/src/client/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/examples/openapi-ts-angular-common/src/client/client/client.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/examples/openapi-ts-angular-common/src/client/client/utils.gen.ts b/examples/openapi-ts-angular-common/src/client/client/utils.gen.ts index 3809e28b1a..f1dfbaaaca 100644 --- a/examples/openapi-ts-angular-common/src/client/client/utils.gen.ts +++ b/examples/openapi-ts-angular-common/src/client/client/utils.gen.ts @@ -180,12 +180,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'], ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/examples/openapi-ts-angular/src/client/client/client.gen.ts b/examples/openapi-ts-angular/src/client/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/examples/openapi-ts-angular/src/client/client/client.gen.ts +++ b/examples/openapi-ts-angular/src/client/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/examples/openapi-ts-angular/src/client/client/utils.gen.ts b/examples/openapi-ts-angular/src/client/client/utils.gen.ts index 3809e28b1a..f1dfbaaaca 100644 --- a/examples/openapi-ts-angular/src/client/client/utils.gen.ts +++ b/examples/openapi-ts-angular/src/client/client/utils.gen.ts @@ -180,12 +180,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'], ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/client.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/client.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/utils.gen.ts b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/utils.gen.ts index 3809e28b1a..f1dfbaaaca 100644 --- a/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/utils.gen.ts +++ b/examples/openapi-ts-tanstack-angular-query-experimental/src/client/client/utils.gen.ts @@ -180,12 +180,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'], ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { From fb09d02f046e6f3acc249ca269676952dc00d0f8 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:06:42 -0600 Subject: [PATCH 06/10] Fix up unit tests --- .../client-angular/__tests__/utils.test.ts | 164 +++++++++--------- 1 file changed, 81 insertions(+), 83 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/utils.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/utils.test.ts index 48961d1edb..689c471e9a 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/utils.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/utils.test.ts @@ -9,16 +9,16 @@ describe('buildUrl', () => { options: Parameters[0]; url: string; }> = [ - { - options: { - path: { - id: new Date('2025-01-01T00:00:00.000Z'), + { + options: { + path: { + id: new Date('2025-01-01T00:00:00.000Z'), + }, + url: '/foo/{id}', }, - url: '/foo/{id}', + url: '/foo/2025-01-01T00:00:00.000Z', }, - url: '/foo/2025-01-01T00:00:00.000Z', - }, - ]; + ]; it.each(scenarios)('builds $url', async ({ options, url }) => { expect(buildUrl(options)).toEqual(url); @@ -30,55 +30,55 @@ describe('getParseAs', () => { content: Parameters[0]; parseAs: ReturnType; }> = [ - { - content: null, - parseAs: 'stream', - }, - { - content: 'application/json', - parseAs: 'json', - }, - { - content: 'application/ld+json', - parseAs: 'json', - }, - { - content: 'application/ld+json;charset=utf-8', - parseAs: 'json', - }, - { - content: 'application/ld+json; charset=utf-8', - parseAs: 'json', - }, - { - content: 'multipart/form-data', - parseAs: 'formData', - }, - { - content: 'application/*', - parseAs: 'blob', - }, - { - content: 'audio/*', - parseAs: 'blob', - }, - { - content: 'image/*', - parseAs: 'blob', - }, - { - content: 'video/*', - parseAs: 'blob', - }, - { - content: 'text/*', - parseAs: 'text', - }, - { - content: 'unsupported', - parseAs: undefined, - }, - ]; + { + content: null, + parseAs: 'stream', + }, + { + content: 'application/json', + parseAs: 'json', + }, + { + content: 'application/ld+json', + parseAs: 'json', + }, + { + content: 'application/ld+json;charset=utf-8', + parseAs: 'json', + }, + { + content: 'application/ld+json; charset=utf-8', + parseAs: 'json', + }, + { + content: 'multipart/form-data', + parseAs: 'formData', + }, + { + content: 'application/*', + parseAs: 'blob', + }, + { + content: 'audio/*', + parseAs: 'blob', + }, + { + content: 'image/*', + parseAs: 'blob', + }, + { + content: 'video/*', + parseAs: 'blob', + }, + { + content: 'text/*', + parseAs: 'text', + }, + { + content: 'unsupported', + parseAs: undefined, + }, + ]; it.each(scenarios)('detects $content as $parseAs', async ({ content, parseAs }) => { expect(getParseAs(content)).toEqual(parseAs); @@ -102,7 +102,7 @@ describe('setAuthParams', () => { }, ], }; - await setAuthParams(options); + await setAuthParams(options, options.security); expect(auth).toHaveBeenCalled(); expect(options.headers.get('baz')).toBe('Bearer foo'); expect(Object.keys(query).length).toBe(0); @@ -116,15 +116,14 @@ describe('setAuthParams', () => { auth, headers, query, - security: [ - { - in: 'query', - name: 'baz', - scheme: 'bearer', - type: 'http', - }, - ], - }); + }, [ + { + in: 'query', + name: 'baz', + scheme: 'bearer', + type: 'http', + }, + ]); expect(auth).toHaveBeenCalled(); expect(headers.get('baz')).toBeNull(); expect(query.baz).toBe('Bearer foo'); @@ -144,7 +143,7 @@ describe('setAuthParams', () => { }, ], }; - await setAuthParams(options); + await setAuthParams(options, options.security); expect(auth).toHaveBeenCalled(); expect(options.headers.get('Authorization')).toBe('foo'); expect(query).toEqual({}); @@ -172,7 +171,7 @@ describe('setAuthParams', () => { }, ], }; - await setAuthParams(options); + await setAuthParams(options, options.security); expect(auth).toHaveBeenCalled(); expect(options.headers.get('baz')).toBe('Bearer foo'); expect(Object.keys(query).length).toBe(0); @@ -191,19 +190,18 @@ describe('setAuthParams', () => { auth, headers, query, - security: [ - { - name: 'baz', - type: 'apiKey', - }, - { - in: 'query', - name: 'baz', - scheme: 'bearer', - type: 'http', - }, - ], - }); + }, [ + { + name: 'baz', + type: 'apiKey', + }, + { + in: 'query', + name: 'baz', + scheme: 'bearer', + type: 'http', + }, + ]); expect(auth).toHaveBeenCalled(); expect(headers.get('baz')).toBeNull(); expect(query.baz).toBe('Bearer foo'); @@ -225,7 +223,7 @@ describe('setAuthParams', () => { }, ], }; - await setAuthParams(options); + await setAuthParams(options, options.security); expect(auth).toHaveBeenCalled(); expect(options.headers.get('Cookie')).toBe('baz=foo'); expect(query).toEqual({}); From eb9cdc424f4e2946506792f07bc2785940390d68 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:23:27 -0600 Subject: [PATCH 07/10] Regenerate snapshots --- .../common/default-class/client/client.gen.ts | 27 +++++++++++++------ .../common/default-class/client/utils.gen.ts | 10 +++---- .../common/default/client/client.gen.ts | 27 +++++++++++++------ .../common/default/client/utils.gen.ts | 10 +++---- .../common/default-class/client/client.gen.ts | 27 +++++++++++++------ .../common/default-class/client/utils.gen.ts | 10 +++---- .../common/default/client/client.gen.ts | 27 +++++++++++++------ .../common/default/client/utils.gen.ts | 10 +++---- .../common/default-class/client/client.gen.ts | 27 +++++++++++++------ .../common/default-class/client/utils.gen.ts | 10 +++---- .../common/default/client/client.gen.ts | 27 +++++++++++++------ .../common/default/client/utils.gen.ts | 10 +++---- .../3.1.x/sse-angular/client/client.gen.ts | 27 +++++++++++++------ .../3.1.x/sse-angular/client/utils.gen.ts | 10 +++---- 14 files changed, 168 insertions(+), 91 deletions(-) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default-class/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.0.x/plugins/@angular/common/default/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default-class/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/plugins/@angular/common/default/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { From 791f92ee22b0a2294847f6363eb377802c850529 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:36:38 -0600 Subject: [PATCH 08/10] Regenerate snapshots --- .../base-url-false/client/client.gen.ts | 27 +++++++++++++------ .../base-url-false/client/utils.gen.ts | 10 +++---- .../base-url-number/client/client.gen.ts | 27 +++++++++++++------ .../base-url-number/client/utils.gen.ts | 10 +++---- .../base-url-strict/client/client.gen.ts | 27 +++++++++++++------ .../base-url-strict/client/utils.gen.ts | 10 +++---- .../base-url-string/client/client.gen.ts | 27 +++++++++++++------ .../base-url-string/client/utils.gen.ts | 10 +++---- .../clean-false/client/client.gen.ts | 27 +++++++++++++------ .../clean-false/client/utils.gen.ts | 10 +++---- .../default/client/client.gen.ts | 27 +++++++++++++------ .../default/client/utils.gen.ts | 10 +++---- .../client/client.gen.ts | 27 +++++++++++++------ .../client/utils.gen.ts | 10 +++---- .../sdk-client-optional/client/client.gen.ts | 27 +++++++++++++------ .../sdk-client-optional/client/utils.gen.ts | 10 +++---- .../sdk-client-required/client/client.gen.ts | 27 +++++++++++++------ .../sdk-client-required/client/utils.gen.ts | 10 +++---- .../tsconfig-node16-sdk/client/client.gen.ts | 27 +++++++++++++------ .../tsconfig-node16-sdk/client/utils.gen.ts | 10 +++---- .../client/client.gen.ts | 27 +++++++++++++------ .../tsconfig-nodenext-sdk/client/utils.gen.ts | 10 +++---- 22 files changed, 264 insertions(+), 143 deletions(-) diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-false/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-number/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-strict/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/base-url-string/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/clean-false/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/default/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/client.gen.ts index 8ffffba628..08856eab1f 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/utils.gen.ts index 1fb8bc6dc1..6f4392cd08 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/import-file-extension-ts/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-optional/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/client.gen.ts index 2446e5d146..996415bec5 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/utils.gen.ts index b9fb1a4421..a43d77a529 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/sdk-client-required/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/client.gen.ts index 4b2e2fa828..2bd0d6d78b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/utils.gen.ts index a8ea0fd61b..40068fa590 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-node16-sdk/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/client.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/client.gen.ts index 4b2e2fa828..2bd0d6d78b 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/client.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/client.gen.ts @@ -1,6 +1,6 @@ // This file is auto-generated by @hey-api/openapi-ts -import type { HttpResponse } from '@angular/common/http'; +import type { HttpHeaders, HttpResponse } from '@angular/common/http'; import { HttpClient, HttpErrorResponse, HttpEventType, HttpRequest } from '@angular/common/http'; import { assertInInjectionContext, @@ -87,6 +87,18 @@ export const createClient = (config: Config = {}): Client => { opts.headers.delete('Content-Type'); } + return opts; + }; + + const finalizeRequest = < + TData = unknown, + ThrowOnError extends boolean = false, + TResponseStyle extends ResponseStyle = 'fields', + >( + opts: RequestOptions & { + headers: HttpHeaders; + }, + ) => { const url = buildUrl(opts as Config & RequestOptions); const req = new HttpRequest(opts.method ?? 'GET', url, getValidRequestBody(opts), { @@ -94,7 +106,7 @@ export const createClient = (config: Config = {}): Client => { ...opts, }); - return { opts, req, url }; + return { req, url }; }; const beforeRequest = async < @@ -105,19 +117,18 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams({ - ...opts, - security: opts.security, - }); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -239,7 +250,7 @@ export const createClient = (config: Config = {}): Client => { throw new Error('Request validation is not supported in requestOptions'); } - return requestOptions(options).req; + return finalizeRequest(requestOptions(options)).req; }, setConfig, sse: { diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/utils.gen.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/utils.gen.ts index a8ea0fd61b..40068fa590 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/utils.gen.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/@hey-api/client-angular/tsconfig-nodenext-sdk/client/utils.gen.ts @@ -183,12 +183,12 @@ export const getParseAs = ( }; export const setAuthParams = async ( - options: Pick, 'security'> & - Pick & { - headers: HttpHeaders; - }, + options: Pick & { + headers: HttpHeaders; + }, + security: Pick, 'security'>['security'] ) => { - for (const auth of options.security) { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { From 219c1ee5b1de6a1aa43e530f853e3abef79b9d15 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:37:52 -0600 Subject: [PATCH 09/10] Regenerate snapshots --- .../client-angular/__tests__/utils.test.ts | 168 +++++++++--------- .../@hey-api/client-angular/bundle/utils.ts | 2 +- 2 files changed, 88 insertions(+), 82 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/utils.test.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/utils.test.ts index 689c471e9a..f35edafe5d 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/utils.test.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/__tests__/utils.test.ts @@ -9,16 +9,16 @@ describe('buildUrl', () => { options: Parameters[0]; url: string; }> = [ - { - options: { - path: { - id: new Date('2025-01-01T00:00:00.000Z'), - }, - url: '/foo/{id}', + { + options: { + path: { + id: new Date('2025-01-01T00:00:00.000Z'), }, - url: '/foo/2025-01-01T00:00:00.000Z', + url: '/foo/{id}', }, - ]; + url: '/foo/2025-01-01T00:00:00.000Z', + }, + ]; it.each(scenarios)('builds $url', async ({ options, url }) => { expect(buildUrl(options)).toEqual(url); @@ -30,55 +30,55 @@ describe('getParseAs', () => { content: Parameters[0]; parseAs: ReturnType; }> = [ - { - content: null, - parseAs: 'stream', - }, - { - content: 'application/json', - parseAs: 'json', - }, - { - content: 'application/ld+json', - parseAs: 'json', - }, - { - content: 'application/ld+json;charset=utf-8', - parseAs: 'json', - }, - { - content: 'application/ld+json; charset=utf-8', - parseAs: 'json', - }, - { - content: 'multipart/form-data', - parseAs: 'formData', - }, - { - content: 'application/*', - parseAs: 'blob', - }, - { - content: 'audio/*', - parseAs: 'blob', - }, - { - content: 'image/*', - parseAs: 'blob', - }, - { - content: 'video/*', - parseAs: 'blob', - }, - { - content: 'text/*', - parseAs: 'text', - }, - { - content: 'unsupported', - parseAs: undefined, - }, - ]; + { + content: null, + parseAs: 'stream', + }, + { + content: 'application/json', + parseAs: 'json', + }, + { + content: 'application/ld+json', + parseAs: 'json', + }, + { + content: 'application/ld+json;charset=utf-8', + parseAs: 'json', + }, + { + content: 'application/ld+json; charset=utf-8', + parseAs: 'json', + }, + { + content: 'multipart/form-data', + parseAs: 'formData', + }, + { + content: 'application/*', + parseAs: 'blob', + }, + { + content: 'audio/*', + parseAs: 'blob', + }, + { + content: 'image/*', + parseAs: 'blob', + }, + { + content: 'video/*', + parseAs: 'blob', + }, + { + content: 'text/*', + parseAs: 'text', + }, + { + content: 'unsupported', + parseAs: undefined, + }, + ]; it.each(scenarios)('detects $content as $parseAs', async ({ content, parseAs }) => { expect(getParseAs(content)).toEqual(parseAs); @@ -112,18 +112,21 @@ describe('setAuthParams', () => { const auth = vi.fn().mockReturnValue('foo'); const headers = new HttpHeaders(); const query: Record = {}; - await setAuthParams({ - auth, - headers, - query, - }, [ + await setAuthParams( { - in: 'query', - name: 'baz', - scheme: 'bearer', - type: 'http', + auth, + headers, + query, }, - ]); + [ + { + in: 'query', + name: 'baz', + scheme: 'bearer', + type: 'http', + }, + ], + ); expect(auth).toHaveBeenCalled(); expect(headers.get('baz')).toBeNull(); expect(query.baz).toBe('Bearer foo'); @@ -186,22 +189,25 @@ describe('setAuthParams', () => { }); const headers = new HttpHeaders(); const query: Record = {}; - await setAuthParams({ - auth, - headers, - query, - }, [ - { - name: 'baz', - type: 'apiKey', - }, + await setAuthParams( { - in: 'query', - name: 'baz', - scheme: 'bearer', - type: 'http', + auth, + headers, + query, }, - ]); + [ + { + name: 'baz', + type: 'apiKey', + }, + { + in: 'query', + name: 'baz', + scheme: 'bearer', + type: 'http', + }, + ], + ); expect(auth).toHaveBeenCalled(); expect(headers.get('baz')).toBeNull(); expect(query.baz).toBe('Bearer foo'); diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts index caa41d6a60..5b4200717e 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts @@ -184,7 +184,7 @@ export const setAuthParams = async ( options: Pick & { headers: HttpHeaders; }, - security: Pick, 'security'>['security'] + security: Pick, 'security'>['security'], ) => { for (const auth of security) { const token = await getAuthToken(auth, options.auth); From 4c5d31160279a0d4d398d10459fc2837f4e2993d Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 23:33:48 -0600 Subject: [PATCH 10/10] Don't return after finding first auth value --- .../src/plugins/@hey-api/client-angular/bundle/utils.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts index 5b4200717e..ee12e7c214 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/bundle/utils.ts @@ -210,8 +210,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } };