From 736d19b950a6e5f2ae9c107b0b6943b44357752d Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 11:59:19 -0600 Subject: [PATCH 01/11] Fix how headers are handled in @hey-api/client-angular --- .../@hey-api/client-angular/bundle/client.ts | 17 +++++++++++++---- .../@hey-api/client-angular/bundle/utils.ts | 7 ++++--- 2 files changed, 17 insertions(+), 7 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 0eb85b6033..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,16 +107,21 @@ export const createClient = (config: Config = {}): Client => { >( options: RequestOptions, ) => { - const { opts, req, url } = requestOptions(options); + const opts = requestOptions(options); if (opts.security) { - await setAuthParams(opts); + opts.headers = await setAuthParams({ + ...opts, + security: opts.security, + }); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -234,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 e6357d61c9..8be01706d7 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 async function setAuthParams( options: Pick & { headers: HttpHeaders; }, -): Promise { +): Promise { for (const auth of options.security ?? []) { const token = await getAuthToken(auth, options.auth); @@ -210,9 +210,10 @@ export async function setAuthParams( break; } - return; + return options.headers; } -} + return options.headers; +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ From 3adc377580f71c0f3ac487f31d5e51b50f282e79 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 14:08:51 -0600 Subject: [PATCH 02/11] 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 07fece90ebf9a2d2521ec3637161b16953111042 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 14:30:44 -0600 Subject: [PATCH 03/11] 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 a6f6b2fbf57ddf6b899e625dbdb1aef921139b62 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 14:52:33 -0600 Subject: [PATCH 04/11] Fix input types on setAuthParams to be able to take references --- .../plugins/@hey-api/client-angular/bundle/client.ts | 5 +---- .../plugins/@hey-api/client-angular/bundle/utils.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 10 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 8be01706d7..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 @@ -180,12 +180,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -210,9 +211,8 @@ export async function setAuthParams( break; } - return options.headers; + return; } - return options.headers; }; export const buildUrl: Client['buildUrl'] = (options) => { From 1268f026036f5dda2209fcdfb8ecb41b61ef633a Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:00:52 -0600 Subject: [PATCH 05/11] Regenerate examples after fixing angular client --- .../src/client/client/client.gen.ts | 24 +++++++++++++++---- .../src/client/client/utils.gen.ts | 11 +++++---- .../src/client/client/client.gen.ts | 24 +++++++++++++++---- .../src/client/client/utils.gen.ts | 11 +++++---- .../src/client/client/client.gen.ts | 24 +++++++++++++++---- .../src/client/client/utils.gen.ts | 11 +++++---- 6 files changed, 75 insertions(+), 30 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 8a905e0552..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 @@ -179,12 +179,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'], +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -211,7 +212,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 8a905e0552..f1dfbaaaca 100644 --- a/examples/openapi-ts-angular/src/client/client/utils.gen.ts +++ b/examples/openapi-ts-angular/src/client/client/utils.gen.ts @@ -179,12 +179,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'], +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -211,7 +212,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 8a905e0552..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 @@ -179,12 +179,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'], +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -211,7 +212,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ From 122422001b3a7bb771a99a3d853922d0c6e8eb31 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:06:42 -0600 Subject: [PATCH 06/11] 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 d4dec71a8d..2a580c9b39 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'); @@ -163,7 +162,7 @@ describe('setAuthParams', () => { }, ], }; - await setAuthParams(options); + await setAuthParams(options, options.security); expect(auth).toHaveBeenCalled(); expect(options.headers.get('Authorization')).toBe('foo'); expect(query).toEqual({}); @@ -191,7 +190,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); @@ -210,19 +209,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'); @@ -244,7 +242,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 73c3df69e1e17af171f15087fc39d4460c49c6be Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:23:27 -0600 Subject: [PATCH 07/11] Regenerate snapshots --- .../common/default-class/client/client.gen.ts | 24 +++++++++++++++---- .../common/default-class/client/utils.gen.ts | 11 +++++---- .../common/default/client/client.gen.ts | 24 +++++++++++++++---- .../common/default/client/utils.gen.ts | 11 +++++---- .../common/default-class/client/client.gen.ts | 24 +++++++++++++++---- .../common/default-class/client/utils.gen.ts | 11 +++++---- .../common/default/client/client.gen.ts | 24 +++++++++++++++---- .../common/default/client/utils.gen.ts | 11 +++++---- .../base-url-false/client/client.gen.ts | 24 +++++++++++++++---- .../base-url-false/client/utils.gen.ts | 11 +++++---- .../base-url-number/client/client.gen.ts | 24 +++++++++++++++---- .../base-url-number/client/utils.gen.ts | 11 +++++---- .../base-url-strict/client/client.gen.ts | 24 +++++++++++++++---- .../base-url-strict/client/utils.gen.ts | 11 +++++---- .../base-url-string/client/client.gen.ts | 24 +++++++++++++++---- .../base-url-string/client/utils.gen.ts | 11 +++++---- .../clean-false/client/client.gen.ts | 24 +++++++++++++++---- .../clean-false/client/utils.gen.ts | 11 +++++---- .../default/client/client.gen.ts | 24 +++++++++++++++---- .../default/client/utils.gen.ts | 11 +++++---- .../client/client.gen.ts | 24 +++++++++++++++---- .../client/utils.gen.ts | 11 +++++---- .../sdk-client-optional/client/client.gen.ts | 24 +++++++++++++++---- .../sdk-client-optional/client/utils.gen.ts | 11 +++++---- .../sdk-client-required/client/client.gen.ts | 24 +++++++++++++++---- .../sdk-client-required/client/utils.gen.ts | 11 +++++---- .../tsconfig-node16-sdk/client/client.gen.ts | 24 +++++++++++++++---- .../tsconfig-node16-sdk/client/utils.gen.ts | 11 +++++---- .../client/client.gen.ts | 24 +++++++++++++++---- .../tsconfig-nodenext-sdk/client/utils.gen.ts | 11 +++++---- .../common/default-class/client/client.gen.ts | 24 +++++++++++++++---- .../common/default-class/client/utils.gen.ts | 11 +++++---- .../common/default/client/client.gen.ts | 24 +++++++++++++++---- .../common/default/client/utils.gen.ts | 11 +++++---- .../3.1.x/sse-angular/client/client.gen.ts | 24 +++++++++++++++---- .../3.1.x/sse-angular/client/utils.gen.ts | 11 +++++---- 36 files changed, 450 insertions(+), 180 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 2239bbe6f7..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 0df2a892b8..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 d78f57f48a..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 d640c9dbfb..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 d78f57f48a..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 d640c9dbfb..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ 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 230de2cf1e..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,16 +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); + await setAuthParams(opts, opts.security); } if (opts.requestValidator) { await opts.requestValidator(opts); } + const { req, url } = finalizeRequest(opts); + return { opts, req, url }; }; @@ -236,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 3ecc10481a..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 @@ -182,12 +182,13 @@ export const getParseAs = ( return; }; -export async function setAuthParams( - options: Pick & { +export const setAuthParams = async ( + options: Pick & { headers: HttpHeaders; }, -): Promise { - for (const auth of options.security ?? []) { + security: Pick, 'security'>['security'] +) => { + for (const auth of security) { const token = await getAuthToken(auth, options.auth); if (!token) { @@ -214,7 +215,7 @@ export async function setAuthParams( return; } -} +}; export const buildUrl: Client['buildUrl'] = (options) => { const url = getUrl({ From 8892b13e6db40e105b81c7fe2fb1e5c1be9c754d Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 15:37:52 -0600 Subject: [PATCH 08/11] 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 2a580c9b39..e5eaa6e991 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'); @@ -205,22 +208,25 @@ describe('setAuthParams', () => { }); const headers = new HttpHeaders(); const query: Record = {}; - await setAuthParams({ - auth, - headers, - query, - }, [ + await setAuthParams( { - name: 'baz', - type: 'apiKey', + auth, + headers, + query, }, - { - 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'); 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 95ed8c06e2ba8fb81ef8c3317c9cda0e62bc6012 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Sat, 9 May 2026 23:33:48 -0600 Subject: [PATCH 09/11] 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; } }; From 603d7ab0f20def3e53aad3389f43eb8b72368c5d Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Tue, 26 May 2026 12:23:38 -0600 Subject: [PATCH 10/11] Regenerate snapshots --- .../openapi-ts-angular-common/src/client/client/utils.gen.ts | 2 -- examples/openapi-ts-angular/src/client/client/utils.gen.ts | 2 -- .../src/client/client/utils.gen.ts | 2 -- .../plugins/@angular/common/default-class/client/utils.gen.ts | 4 +--- .../2.0.x/plugins/@angular/common/default/client/utils.gen.ts | 4 +--- .../plugins/@angular/common/default-class/client/utils.gen.ts | 4 +--- .../3.0.x/plugins/@angular/common/default/client/utils.gen.ts | 4 +--- .../client-angular/base-url-false/client/utils.gen.ts | 4 +--- .../client-angular/base-url-number/client/utils.gen.ts | 4 +--- .../client-angular/base-url-strict/client/utils.gen.ts | 4 +--- .../client-angular/base-url-string/client/utils.gen.ts | 4 +--- .../@hey-api/client-angular/clean-false/client/utils.gen.ts | 4 +--- .../@hey-api/client-angular/default/client/utils.gen.ts | 4 +--- .../import-file-extension-ts/client/utils.gen.ts | 4 +--- .../client-angular/sdk-client-optional/client/utils.gen.ts | 4 +--- .../client-angular/sdk-client-required/client/utils.gen.ts | 4 +--- .../client-angular/tsconfig-node16-sdk/client/utils.gen.ts | 4 +--- .../client-angular/tsconfig-nodenext-sdk/client/utils.gen.ts | 4 +--- .../plugins/@angular/common/default-class/client/utils.gen.ts | 4 +--- .../3.1.x/plugins/@angular/common/default/client/utils.gen.ts | 4 +--- .../test/__snapshots__/3.1.x/sse-angular/client/utils.gen.ts | 4 +--- 21 files changed, 18 insertions(+), 60 deletions(-) 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 f1dfbaaaca..a1d271372d 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 @@ -209,8 +209,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 f1dfbaaaca..a1d271372d 100644 --- a/examples/openapi-ts-angular/src/client/client/utils.gen.ts +++ b/examples/openapi-ts-angular/src/client/client/utils.gen.ts @@ -209,8 +209,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 f1dfbaaaca..a1d271372d 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 @@ -209,8 +209,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 6f4392cd08..2f356087d5 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 40068fa590..bf3bad021e 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 40068fa590..bf3bad021e 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; 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 a43d77a529..e9c964de30 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 @@ -186,7 +186,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); @@ -212,8 +212,6 @@ export const setAuthParams = async ( options.headers = options.headers.set(name, token); break; } - - return; } }; From 3769c88deb2b193f42fd2c10b2a84fe76513a788 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Tue, 26 May 2026 12:55:19 -0600 Subject: [PATCH 11/11] Regenerate snapshots and examples --- .../client-angular/__tests__/utils.test.ts | 49 +++++-------------- 1 file changed, 12 insertions(+), 37 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 e5eaa6e991..e797190802 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 @@ -135,18 +135,21 @@ describe('setAuthParams', () => { it('sets access token in query when query is initially undefined', async () => { const auth = vi.fn().mockReturnValue('foo'); const headers = new HttpHeaders(); - const opts: Parameters[0] = { + const security: Parameters[1] = [ + { + in: 'query', + name: 'baz', + type: 'apiKey', + }, + ]; + const opts: Parameters[0] & { + security: Parameters[1]; + } = { auth, headers, - security: [ - { - in: 'query', - name: 'baz', - type: 'apiKey', - }, - ], + security, }; - await setAuthParams(opts); + await setAuthParams(opts, opts.security); expect(auth).toHaveBeenCalled(); expect(opts.query).toEqual({ baz: 'foo' }); }); @@ -171,34 +174,6 @@ describe('setAuthParams', () => { expect(query).toEqual({}); }); - it('sets first scheme only', async () => { - const auth = vi.fn().mockReturnValue('foo'); - const headers = new HttpHeaders(); - const query: Record = {}; - const options = { - auth, - headers, - query, - security: [ - { - name: 'baz', - scheme: 'bearer' as const, - type: 'http' as const, - }, - { - in: 'query' as const, - name: 'baz', - scheme: 'bearer' as const, - type: 'http' as const, - }, - ], - }; - await setAuthParams(options, options.security); - expect(auth).toHaveBeenCalled(); - expect(options.headers.get('baz')).toBe('Bearer foo'); - expect(Object.keys(query).length).toBe(0); - }); - it('sets first scheme with token', async () => { const auth = vi.fn().mockImplementation((auth: Auth) => { if (auth.type === 'apiKey') {