From 6fd7985d36882cdb3bbece31255a33b93e3a4b06 Mon Sep 17 00:00:00 2001 From: Arpit Bruno Date: Mon, 13 Jul 2026 12:01:58 +0530 Subject: [PATCH] skips api key query param when value is empty --- packages/oc-docs/src/runner/RequestExecutor.spec.ts | 7 +++++++ packages/oc-docs/src/runner/RequestExecutor.ts | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/oc-docs/src/runner/RequestExecutor.spec.ts b/packages/oc-docs/src/runner/RequestExecutor.spec.ts index 00f214ef..2ba9acf6 100644 --- a/packages/oc-docs/src/runner/RequestExecutor.spec.ts +++ b/packages/oc-docs/src/runner/RequestExecutor.spec.ts @@ -27,6 +27,13 @@ describe('applyApiKeyToUrl', () => { const auth = { type: 'apikey', key: 'api_key', value: 'secret123', placement: 'query' }; expect(applyApiKeyToUrl('api.example.com/data', auth)).toBe('api.example.com/data'); }); + + it('leaves the url untouched when the value is empty', () => { + const auth = { type: 'apikey', key: 'api_key', value: '', placement: 'query' }; + expect(applyApiKeyToUrl('https://api.example.com/data', auth)).toBe( + 'https://api.example.com/data' + ); + }); }); describe('RequestExecutor', () => { diff --git a/packages/oc-docs/src/runner/RequestExecutor.ts b/packages/oc-docs/src/runner/RequestExecutor.ts index 9bcd95a3..e4ca2b0d 100644 --- a/packages/oc-docs/src/runner/RequestExecutor.ts +++ b/packages/oc-docs/src/runner/RequestExecutor.ts @@ -6,7 +6,7 @@ import { classifyRequestError, DEFAULT_TIMEOUT_MS } from './classifyRequestError import stripJsonComments from 'strip-json-comments'; export const applyApiKeyToUrl = (url: string, auth: Record | undefined): string => { - if (auth?.type !== 'apikey' || auth.placement !== 'query' || !auth.key) { + if (auth?.type !== 'apikey' || auth.placement !== 'query' || !auth.key || !auth.value) { return url; }