Skip to content

Conversation

@Dima-Bulavenko
Copy link

What's the problem?

When using runtimeConfigPath with a relative path in a nested output directory, the generated import path is incorrect. The generator doesn't calculate the proper relative path from the generated file to the config file.

Folder Structure

root/opentapi-ts.config.ts

import { defineConfig } from '@hey-api/openapi-ts';

export default defineConfig({
  input: './openapi.json',
  output: './gen',
  plugins: [
    {
      name: '@hey-api/client-axios',
      runtimeConfigPath: './client_config.ts',
    },
  ],
})

root/client_config.ts

import type { CreateClientConfig } from './gen/client.gen';

export const createClientConfig: CreateClientConfig = (config) => ({
  ...config,
  baseURL: 'http://localhost:8000',
});

root/gen/client.get.ts

// This file is auto-generated by @hey-api/openapi-ts

import { type ClientOptions, type Config, createClient, createConfig } from './client';
import { createClientConfig } from './client_config.ts'; // THIS IMPORT IS INCORRECT, IT SHOULD REFERENCE '../client_config.ts'
import type { ClientOptions as ClientOptions2 } from './types.gen';

/**
 * The `createClientConfig()` function will be called on client initialization
 * and the returned object will become the client's initial configuration.
 *
 * You may want to initialize your client this way instead of calling
 * `setConfig()`. This is useful for example if you're using Next.js
 * to ensure your client always has the correct values.
 */
export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (override?: Config<ClientOptions & T>) => Config<Required<ClientOptions> & T>;

export const client = createClient(createClientConfig(createConfig<ClientOptions2>()));

Fixed bug where runtimeConfigPath with relative paths would generate
incorrect import statements in nested output directories.

Changed getBindingPath() to only skip relative path calculation for
absolute paths, allowing proper relative path resolution for external
files with relative paths.
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@changeset-bot
Copy link

changeset-bot bot commented Oct 25, 2025

⚠️ No Changeset found

Latest commit: 0faccd4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 25, 2025

@Dima-Bulavenko is attempting to deploy a commit to the Hey API Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug 🔥 Something isn't working client Client package related labels Oct 25, 2025
@Dima-Bulavenko Dima-Bulavenko marked this pull request as draft October 25, 2025 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug 🔥 Something isn't working client Client package related size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant