From 1193c4dce77e0cb02c32b25661f22065a18bd095 Mon Sep 17 00:00:00 2001 From: Lubos Date: Wed, 10 Sep 2025 20:12:55 +0800 Subject: [PATCH] fix(config): correctly load user-defined hooks --- .changeset/odd-fireants-lay.md | 5 +++++ .../main/test/openapi-ts.config.ts | 16 ++++++++++++++-- packages/openapi-ts/src/config/parser.ts | 4 ++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .changeset/odd-fireants-lay.md diff --git a/.changeset/odd-fireants-lay.md b/.changeset/odd-fireants-lay.md new file mode 100644 index 0000000000..3fa74523f7 --- /dev/null +++ b/.changeset/odd-fireants-lay.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix(config): correctly load user-defined hooks diff --git a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts index 3c31fd0299..95aa64e587 100644 --- a/packages/openapi-ts-tests/main/test/openapi-ts.config.ts +++ b/packages/openapi-ts-tests/main/test/openapi-ts.config.ts @@ -36,9 +36,9 @@ export default defineConfig(() => { '3.1.x', // 'invalid', // 'openai.yaml', - // 'full.yaml', + 'full.yaml', // 'opencode.yaml', - 'sdk-instance.yaml', + // 'sdk-instance.yaml', // 'validators-circular-ref-2.yaml', // 'zoom-video-sdk.json', ), @@ -98,6 +98,12 @@ export default defineConfig(() => { }, hooks: { operations: { + getKind() { + // noop + }, + isMutation() { + // noop + }, isQuery: (op) => { if (op.method === 'post' && op.path === '/search') { return true; @@ -227,6 +233,12 @@ export default defineConfig(() => { } return undefined; }, + isMutation() { + // noop + }, + isQuery: () => { + // noop + }, }, }, }, diff --git a/packages/openapi-ts/src/config/parser.ts b/packages/openapi-ts/src/config/parser.ts index 66e4914865..2e9328ecc5 100644 --- a/packages/openapi-ts/src/config/parser.ts +++ b/packages/openapi-ts/src/config/parser.ts @@ -40,6 +40,10 @@ export const getParser = (userConfig: UserConfig): Config['parser'] => { }; if (userConfig.parser) { + if (userConfig.parser.hooks) { + parser.hooks = userConfig.parser.hooks; + } + if (userConfig.parser.pagination?.keywords) { parser.pagination.keywords = userConfig.parser.pagination.keywords; }