From 9d93198ad22c3ed14519408c1ba2cb27dd7de0ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Aguiar?= Date: Thu, 14 Aug 2025 17:51:55 -0300 Subject: [PATCH] feat(js-sdk): support per-request custom headers --- config/clients/js/template/apiInner.mustache | 2 +- .../clients/js/template/tests/client.test.ts.mustache | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/config/clients/js/template/apiInner.mustache b/config/clients/js/template/apiInner.mustache index ba647cd5a..a9a62c1f4 100644 --- a/config/clients/js/template/apiInner.mustache +++ b/config/clients/js/template/apiInner.mustache @@ -171,7 +171,7 @@ export const {{classname}}AxiosParamCreator = function (configuration: Configura {{/bodyParam}} setSearchParams(localVarUrlObj, localVarQueryParameter, options.query); - localVarRequestOptions.headers = {...localVarHeaderParameter, ...options.headers}; + localVarRequestOptions.headers = { ...baseOptions?.headers, ...localVarHeaderParameter, ...options.headers }; {{#hasFormParams}} localVarRequestOptions.data = localVarFormParams{{#vendorExtensions}}{{^multipartFormData}}.toString(){{/multipartFormData}}{{/vendorExtensions}}; {{/hasFormParams}} diff --git a/config/clients/js/template/tests/client.test.ts.mustache b/config/clients/js/template/tests/client.test.ts.mustache index 1b7cff110..e20643e0b 100644 --- a/config/clients/js/template/tests/client.test.ts.mustache +++ b/config/clients/js/template/tests/client.test.ts.mustache @@ -99,6 +99,17 @@ describe("{{appTitleCaseName}} Client", () => { expect(response.stores).toHaveLength(1); expect(response.stores?.[0]).toMatchObject(store); }); + + it("should include custom headers when provided", async () => { + const scope = nock(defaultConfiguration.getBasePath()) + .get("/stores") + .matchHeader("X-Correlation-ID", "abc123") + .reply(200, { continuation_token: "", stores: [] }); + + await fgaClient.listStores({ headers: { "X-Correlation-ID": "abc123" } }); + + expect(scope.isDone()).toBe(true); + }); }); describe("CreateStore", () => {