From 10b2441773b231956b3551273b20ccf0afd44c27 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Oct 2025 03:01:46 +0000 Subject: [PATCH 1/4] Initial plan From 48958dbe3c7f6fe922232ea03464dd93094d2d5d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Oct 2025 03:17:34 +0000 Subject: [PATCH 2/4] Export Operation type to fix methodNameBuilder TypeScript errors Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- packages/openapi-ts/src/index.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/openapi-ts/src/index.ts b/packages/openapi-ts/src/index.ts index 81cde15a2..e4fbe87cf 100644 --- a/packages/openapi-ts/src/index.ts +++ b/packages/openapi-ts/src/index.ts @@ -78,6 +78,7 @@ export type { ExpressionTransformer } from './plugins/@hey-api/transformers/expr export type { TypeTransformer } from './plugins/@hey-api/transformers/types'; export { definePluginConfig } from './plugins/shared/utils/config'; export { compiler, tsc } from './tsc'; +export type { Operation } from './types/client'; export type { UserConfig } from './types/config'; export type { LegacyIR } from './types/types'; export { utils } from './utils/exports'; From 774e408c4f20c532037e12f7cd687655040b8fb8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 27 Oct 2025 09:58:27 +0000 Subject: [PATCH 3/4] Add test to verify Operation type is properly exported Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com> --- .../openapi-ts/src/__tests__/exports.test.ts | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 packages/openapi-ts/src/__tests__/exports.test.ts diff --git a/packages/openapi-ts/src/__tests__/exports.test.ts b/packages/openapi-ts/src/__tests__/exports.test.ts new file mode 100644 index 000000000..a26acd5aa --- /dev/null +++ b/packages/openapi-ts/src/__tests__/exports.test.ts @@ -0,0 +1,45 @@ +import { describe, expect, it } from 'vitest'; + +import type { IR, Operation } from '~/index'; + +describe('exports', () => { + it('should export Operation type', () => { + // This test verifies that Operation type can be imported from the main index + // If this compiles without TypeScript errors, the type is properly exported + type MethodNameBuilder = ( + operation: IR.OperationObject | Operation, + ) => string; + + const builder: MethodNameBuilder = (operation) => { + if ('operationId' in operation && operation.operationId) { + return operation.operationId; + } + if ('id' in operation && operation.id) { + return operation.id; + } + return operation.path ?? ''; + }; + + expect(typeof builder).toBe('function'); + }); + + it('should allow Operation type in methodNameBuilder signature', () => { + // Verify that Operation type can be used in the exact same signature as the SDK plugin + // This matches the type signature from packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts + type SdkMethodNameBuilder = ( + operation: IR.OperationObject | Operation, + ) => string; + + const testBuilder: SdkMethodNameBuilder = (operation) => { + // Test that we can access properties from both IR.OperationObject and Operation + const id = 'id' in operation ? operation.id : undefined; + const operationId = + 'operationId' in operation ? operation.operationId : undefined; + const path = operation.path; + + return id || operationId || path || 'default'; + }; + + expect(typeof testBuilder).toBe('function'); + }); +}); From 857c464ac04832c3bf26f33af3c1c90ccf67fda1 Mon Sep 17 00:00:00 2001 From: Lubos Date: Mon, 27 Oct 2025 19:04:04 +0800 Subject: [PATCH 4/4] test: remove test --- .changeset/loose-baboons-switch.md | 5 +++ .../openapi-ts/src/__tests__/exports.test.ts | 45 ------------------- 2 files changed, 5 insertions(+), 45 deletions(-) create mode 100644 .changeset/loose-baboons-switch.md delete mode 100644 packages/openapi-ts/src/__tests__/exports.test.ts diff --git a/.changeset/loose-baboons-switch.md b/.changeset/loose-baboons-switch.md new file mode 100644 index 000000000..81f95d6d4 --- /dev/null +++ b/.changeset/loose-baboons-switch.md @@ -0,0 +1,5 @@ +--- +'@hey-api/openapi-ts': patch +--- + +fix(types): export Operation type diff --git a/packages/openapi-ts/src/__tests__/exports.test.ts b/packages/openapi-ts/src/__tests__/exports.test.ts deleted file mode 100644 index a26acd5aa..000000000 --- a/packages/openapi-ts/src/__tests__/exports.test.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { describe, expect, it } from 'vitest'; - -import type { IR, Operation } from '~/index'; - -describe('exports', () => { - it('should export Operation type', () => { - // This test verifies that Operation type can be imported from the main index - // If this compiles without TypeScript errors, the type is properly exported - type MethodNameBuilder = ( - operation: IR.OperationObject | Operation, - ) => string; - - const builder: MethodNameBuilder = (operation) => { - if ('operationId' in operation && operation.operationId) { - return operation.operationId; - } - if ('id' in operation && operation.id) { - return operation.id; - } - return operation.path ?? ''; - }; - - expect(typeof builder).toBe('function'); - }); - - it('should allow Operation type in methodNameBuilder signature', () => { - // Verify that Operation type can be used in the exact same signature as the SDK plugin - // This matches the type signature from packages/openapi-ts/src/plugins/@hey-api/sdk/types.d.ts - type SdkMethodNameBuilder = ( - operation: IR.OperationObject | Operation, - ) => string; - - const testBuilder: SdkMethodNameBuilder = (operation) => { - // Test that we can access properties from both IR.OperationObject and Operation - const id = 'id' in operation ? operation.id : undefined; - const operationId = - 'operationId' in operation ? operation.operationId : undefined; - const path = operation.path; - - return id || operationId || path || 'default'; - }; - - expect(typeof testBuilder).toBe('function'); - }); -});