From 663c025149927a5835e5f71ed94d9dabc69ecdc4 Mon Sep 17 00:00:00 2001 From: Lagoni Date: Tue, 7 Jul 2026 21:11:03 +0200 Subject: [PATCH 1/2] fix(openapi): remove Node-specific 'url' import from generated HTTP client URL and URLSearchParams are globals in Node.js and browsers; importing them from 'url' made generated packages fail to compile with TS2307 (Cannot find module 'url') unless the consumer had @types/node. With the node-fetch import already dropped in favor of the global fetch, generated HTTP clients now need no imports at all. Regenerated snapshots, runtime fixtures and the openapi-http-client example (the example also catches up with the native-fetch change, which had not regenerated it). Co-Authored-By: Claude Fable 5 --- examples/openapi-http-client/src/generated/http_client.ts | 1 - .../generators/typescript/channels/protocols/http/client.ts | 4 +++- .../generators/typescript/__snapshots__/channels.spec.ts.snap | 2 -- test/runtime/typescript/src/openapi/channels/http_client.ts | 1 - .../typescript/src/request-reply/channels/http_client.ts | 1 - 5 files changed, 3 insertions(+), 6 deletions(-) diff --git a/examples/openapi-http-client/src/generated/http_client.ts b/examples/openapi-http-client/src/generated/http_client.ts index 988d0bf6..bc1ad414 100644 --- a/examples/openapi-http-client/src/generated/http_client.ts +++ b/examples/openapi-http-client/src/generated/http_client.ts @@ -11,7 +11,6 @@ import {BankAccount} from './payload/BankAccount'; import {GetV2ConnectReferenceIdParameters} from './parameter/GetV2ConnectReferenceIdParameters'; import {GetV2UsersSafepayAccountIdBankAccountsParameters} from './parameter/GetV2UsersSafepayAccountIdBankAccountsParameters'; import {PostV2ConnectHeaders} from './headers/PostV2ConnectHeaders'; -import { URLSearchParams, URL } from 'url'; // ============================================================================ // Common Types - Shared across all HTTP client functions diff --git a/src/codegen/generators/typescript/channels/protocols/http/client.ts b/src/codegen/generators/typescript/channels/protocols/http/client.ts index 49589169..56fd19af 100644 --- a/src/codegen/generators/typescript/channels/protocols/http/client.ts +++ b/src/codegen/generators/typescript/channels/protocols/http/client.ts @@ -75,12 +75,14 @@ export function renderHttpFetchClient({ ${functionCode}`; + // URL and URLSearchParams are globals in Node.js and browsers; importing them + // from 'url' would require @types/node in every consuming package. return { messageType, replyType, code, functionName, - dependencies: [`import { URLSearchParams, URL } from 'url';`], + dependencies: [], functionType: ChannelFunctionTypes.HTTP_CLIENT }; } diff --git a/test/codegen/generators/typescript/__snapshots__/channels.spec.ts.snap b/test/codegen/generators/typescript/__snapshots__/channels.spec.ts.snap index 062c32ea..d051c117 100644 --- a/test/codegen/generators/typescript/__snapshots__/channels.spec.ts.snap +++ b/test/codegen/generators/typescript/__snapshots__/channels.spec.ts.snap @@ -11,7 +11,6 @@ exports[`channels typescript OpenAPI input should generate HTTP client protocol "import {Pet} from './../../../../../payloads/Pet'; import * as FindPetsByStatusAndCategoryResponseModule from './../../../../../payloads/FindPetsByStatusAndCategoryResponse'; import {FindPetsByStatusAndCategoryParameters} from './../../../../../parameters/FindPetsByStatusAndCategoryParameters'; -import { URLSearchParams, URL } from 'url'; // ============================================================================ // Common Types - Shared across all HTTP client functions @@ -1932,7 +1931,6 @@ export {http_client}; exports[`channels typescript protocol-specific code generation should generate HTTP client protocol code for request/reply: http_client-protocol-code 1`] = ` "import * as TestPayloadModelModule from './../../../../../payloads/TestPayloadModel'; -import { URLSearchParams, URL } from 'url'; // ============================================================================ // Common Types - Shared across all HTTP client functions diff --git a/test/runtime/typescript/src/openapi/channels/http_client.ts b/test/runtime/typescript/src/openapi/channels/http_client.ts index ea4cc3f6..26eb1f6a 100644 --- a/test/runtime/typescript/src/openapi/channels/http_client.ts +++ b/test/runtime/typescript/src/openapi/channels/http_client.ts @@ -9,7 +9,6 @@ import {AUser} from './../payloads/AUser'; import {AnUploadedResponse} from './../payloads/AnUploadedResponse'; import {FindPetsByStatusAndCategoryParameters} from './../parameters/FindPetsByStatusAndCategoryParameters'; import {FindPetsByStatusAndCategoryHeaders} from './../headers/FindPetsByStatusAndCategoryHeaders'; -import { URLSearchParams, URL } from 'url'; // ============================================================================ // Common Types - Shared across all HTTP client functions diff --git a/test/runtime/typescript/src/request-reply/channels/http_client.ts b/test/runtime/typescript/src/request-reply/channels/http_client.ts index 2555c434..5b4686ea 100644 --- a/test/runtime/typescript/src/request-reply/channels/http_client.ts +++ b/test/runtime/typescript/src/request-reply/channels/http_client.ts @@ -10,7 +10,6 @@ import {NotFound} from './../payloads/NotFound'; import {ItemResponse} from './../payloads/ItemResponse'; import {UserItemsParameters} from './../parameters/UserItemsParameters'; import {ItemRequestHeaders} from './../headers/ItemRequestHeaders'; -import { URLSearchParams, URL } from 'url'; // ============================================================================ // Common Types - Shared across all HTTP client functions From 9ad5306cc5955ad9cc0904488e0eca81b4ef6c1e Mon Sep 17 00:00:00 2001 From: jonaslagoni Date: Wed, 8 Jul 2026 10:55:42 +0200 Subject: [PATCH 2/2] docs: drop redundant comment on empty http client dependencies Co-Authored-By: Claude Opus 4.8 (1M context) --- .../generators/typescript/channels/protocols/http/client.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/codegen/generators/typescript/channels/protocols/http/client.ts b/src/codegen/generators/typescript/channels/protocols/http/client.ts index 56fd19af..8c57aec7 100644 --- a/src/codegen/generators/typescript/channels/protocols/http/client.ts +++ b/src/codegen/generators/typescript/channels/protocols/http/client.ts @@ -75,8 +75,6 @@ export function renderHttpFetchClient({ ${functionCode}`; - // URL and URLSearchParams are globals in Node.js and browsers; importing them - // from 'url' would require @types/node in every consuming package. return { messageType, replyType,