client-axios, runtimeConfigPath, client.gent.ts & generated "import createClientConfig from path" #2150
Answered
by
mrlubos
thekingofspain
asked this question in
Q&A
-
I need some help on code generation option such that the client.gen.ts file creates the proper path for the import line for the createClientConfig. I am using the following UserConfig to generate a series of client from the an openapi.json file: const userConfig: UserConfig = {
input: {
path: resolveRoot("config/api/Api.openapi.json"),
filters: config.includeTags ? {
tags: { include: config.includeTags }
} : {
tags: { exclude: config.excludeTags || [] }
}
},
output: {
format: "prettier",
lint: "eslint",
path: config.outputPath,
clean: true // Optional: clean output directory before generation
},
plugins: [
{
name: "@hey-api/client-axios",
runtimeConfigPath: "common/src/api/utils/client-config.ts",
},
"@hey-api/schemas",
{
name: "@hey-api/transformers",
dates: true,
},
{
name: "@hey-api/typescript",
enums: "typescript",
},
{
name: "@hey-api/sdk",
transformer: true
}
],
}; my directory structure: root
- config/{apiName} /* Api.openapi.json */
- scripts /* generate-clients.ts script *?
- common
-- src
--- api/{apiName}
---- client/{clientName}
---- utils/client-config.ts I have tried alot of options around the runtimeConfigPath value passed to the client-axios, but one of two things happened:
root> npm run clients:generate
> project@0.0.1 clients:generate
> tsx scripts/generate-all-clients.ts
🚀 Starting client generation...
⚙️ Generating core client...
⏳ Generating from config\api\AOI_FastApi.openapi.json
🔥 Unexpected error occurred. Log saved to openapi-ts-error-1749482162833.log
🔥 Unexpected error occurred. File with id common/src/api/util/client-config.ts does not exist
❌ Critical error in core client generation:
Message: File with id common/src/api/util/client-config.ts does not exist
Stack: Error: File with id common/src/api/util/client-config.ts does not exist
at le.relativePathToFile (node_modules\@hey-api\openapi-ts\src\generate\files.ts:231:15)
at createClient (node_modules\@hey-api\openapi-ts\src\plugins\@hey-api\client-core\client.ts:54:22)
at Object.mt (node_modules\@hey-api\openapi-ts\src\plugins\@hey-api\client-core\plugin.ts:14:3)
at generateOutput (node_modules\@hey-api\openapi-ts\src\generate\output.ts:142:12)
at Hs (node_modules\@hey-api\openapi-ts\src\createClient.ts:246:13)
at async Promise.all (index 0)
at async yN (node_modules\@hey-api\openapi-ts\src\index.ts:46:21)
at async generateClients (scripts\generate-all-clients.ts:101:7)
import { createClientConfig } from '../../../../../../../../../client-config'; /* expecting "../../utils/client-config" */ |
Beta Was this translation helpful? Give feedback.
Answered by
mrlubos
Jun 9, 2025
Replies: 1 comment 1 reply
-
Did you try |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
thekingofspain
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you try
./common/src/api/utils/client-config.ts
? I need to improve this btw