From 52228fd785893cc2065c39310a8f6f52076ac21f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Feb 2026 10:04:43 +0000 Subject: [PATCH 1/5] Initial plan From 59da77d6cc272017bc12622cd168497cde72fe88 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Feb 2026 10:11:04 +0000 Subject: [PATCH 2/5] Resolve runtimeConfigPath relative to output directory Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../plugins/@hey-api/client-core/client.ts | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts index c2578ab3a3..6917a342e2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts @@ -1,3 +1,5 @@ +import path from 'node:path'; + import { parseUrl } from '@hey-api/shared'; import { getTypedConfig } from '../../../config/utils'; @@ -41,9 +43,23 @@ export const createClient: PluginHandler = ({ plugin }) => { }); const { runtimeConfigPath } = plugin.config; - const symbolCreateClientConfig = runtimeConfigPath + let resolvedRuntimeConfigPath: string | undefined; + if (runtimeConfigPath) { + const config = getTypedConfig(plugin); + const outputPath = config.output.path; + // Resolve the runtimeConfigPath from the current working directory + const absoluteRuntimeConfigPath = path.resolve(process.cwd(), runtimeConfigPath); + // Calculate the relative path from the output directory to the runtime config file + resolvedRuntimeConfigPath = path.relative(outputPath, absoluteRuntimeConfigPath); + // Ensure the path uses forward slashes and starts with ./ or ../ + resolvedRuntimeConfigPath = resolvedRuntimeConfigPath.split(path.sep).join('/'); + if (!resolvedRuntimeConfigPath.startsWith('.')) { + resolvedRuntimeConfigPath = `./${resolvedRuntimeConfigPath}`; + } + } + const symbolCreateClientConfig = resolvedRuntimeConfigPath ? plugin.symbol('createClientConfig', { - external: runtimeConfigPath, + external: resolvedRuntimeConfigPath, }) : undefined; From fb60f3f667a009a0ad446ce9984a73cff2b502ef Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Feb 2026 10:15:34 +0000 Subject: [PATCH 3/5] Update path resolution logic for runtimeConfigPath Handle both absolute/CWD-relative paths and output-relative paths properly Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../plugins/@hey-api/client-core/client.ts | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts index 6917a342e2..4f593e8ac1 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts @@ -47,14 +47,22 @@ export const createClient: PluginHandler = ({ plugin }) => { if (runtimeConfigPath) { const config = getTypedConfig(plugin); const outputPath = config.output.path; - // Resolve the runtimeConfigPath from the current working directory - const absoluteRuntimeConfigPath = path.resolve(process.cwd(), runtimeConfigPath); - // Calculate the relative path from the output directory to the runtime config file - resolvedRuntimeConfigPath = path.relative(outputPath, absoluteRuntimeConfigPath); - // Ensure the path uses forward slashes and starts with ./ or ../ - resolvedRuntimeConfigPath = resolvedRuntimeConfigPath.split(path.sep).join('/'); - if (!resolvedRuntimeConfigPath.startsWith('.')) { - resolvedRuntimeConfigPath = `./${resolvedRuntimeConfigPath}`; + + // If the path starts with './' or '/' (absolute or relative to CWD), + // resolve it from the current working directory and make it relative to output + if (runtimeConfigPath.startsWith('./') || path.isAbsolute(runtimeConfigPath)) { + // Resolve the runtimeConfigPath from the current working directory + const absoluteRuntimeConfigPath = path.resolve(process.cwd(), runtimeConfigPath); + // Calculate the relative path from the output directory to the runtime config file + resolvedRuntimeConfigPath = path.relative(outputPath, absoluteRuntimeConfigPath); + // Ensure the path uses forward slashes and starts with ./ or ../ + resolvedRuntimeConfigPath = resolvedRuntimeConfigPath.split(path.sep).join('/'); + if (!resolvedRuntimeConfigPath.startsWith('.')) { + resolvedRuntimeConfigPath = `./${resolvedRuntimeConfigPath}`; + } + } else { + // Path is already relative to output (e.g., '../hey-api'), use it as-is + resolvedRuntimeConfigPath = runtimeConfigPath; } } const symbolCreateClientConfig = resolvedRuntimeConfigPath From e629cb14a31a9673ab656acb038a45024f3bdc62 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Feb 2026 10:20:56 +0000 Subject: [PATCH 4/5] Address code review feedback on path resolution - Only resolve paths starting with './' or absolute paths - Paths starting with '../' are kept as-is (already relative to output) - Use path.resolve() without process.cwd() for cleaner code Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../openapi-ts/src/plugins/@hey-api/client-core/client.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts index 4f593e8ac1..e2908b5afa 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts @@ -48,11 +48,11 @@ export const createClient: PluginHandler = ({ plugin }) => { const config = getTypedConfig(plugin); const outputPath = config.output.path; - // If the path starts with './' or '/' (absolute or relative to CWD), + // If the path starts with './' or is absolute, // resolve it from the current working directory and make it relative to output if (runtimeConfigPath.startsWith('./') || path.isAbsolute(runtimeConfigPath)) { // Resolve the runtimeConfigPath from the current working directory - const absoluteRuntimeConfigPath = path.resolve(process.cwd(), runtimeConfigPath); + const absoluteRuntimeConfigPath = path.resolve(runtimeConfigPath); // Calculate the relative path from the output directory to the runtime config file resolvedRuntimeConfigPath = path.relative(outputPath, absoluteRuntimeConfigPath); // Ensure the path uses forward slashes and starts with ./ or ../ @@ -61,7 +61,7 @@ export const createClient: PluginHandler = ({ plugin }) => { resolvedRuntimeConfigPath = `./${resolvedRuntimeConfigPath}`; } } else { - // Path is already relative to output (e.g., '../hey-api'), use it as-is + // Path is already relative to output (e.g., '../hey-api' or 'my-config'), use it as-is resolvedRuntimeConfigPath = runtimeConfigPath; } } From df48dba0207b76c0782979fb59b29a461aa92beb Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 14 Feb 2026 10:22:35 +0000 Subject: [PATCH 5/5] Add comprehensive comments explaining path resolution strategy Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../openapi-ts/src/plugins/@hey-api/client-core/client.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts index e2908b5afa..977d22707b 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts @@ -48,8 +48,11 @@ export const createClient: PluginHandler = ({ plugin }) => { const config = getTypedConfig(plugin); const outputPath = config.output.path; - // If the path starts with './' or is absolute, - // resolve it from the current working directory and make it relative to output + // Path resolution strategy: + // - Paths starting with './' or absolute paths are assumed to be relative to CWD (project root) + // and need to be resolved to be relative to the output directory + // - Paths starting with '../' or without './' prefix are assumed to be already relative + // to the output directory and are used as-is if (runtimeConfigPath.startsWith('./') || path.isAbsolute(runtimeConfigPath)) { // Resolve the runtimeConfigPath from the current working directory const absoluteRuntimeConfigPath = path.resolve(runtimeConfigPath);