Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/oc-docs/src/runner/RequestExecutor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/oc-docs/src/runner/RequestExecutor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { classifyRequestError, DEFAULT_TIMEOUT_MS } from './classifyRequestError
import stripJsonComments from 'strip-json-comments';

export const applyApiKeyToUrl = (url: string, auth: Record<string, unknown> | undefined): string => {
if (auth?.type !== 'apikey' || auth.placement !== 'query' || !auth.key) {
if (auth?.type !== 'apikey' || auth.placement !== 'query' || !auth.key || !auth.value) {
return url;
}

Expand Down
Loading