From b92f97a860ce2a116ef8d82ab9c7df25093bf5e9 Mon Sep 17 00:00:00 2001 From: Muzzaiyyan Hussain Date: Thu, 30 Oct 2025 21:27:20 +0530 Subject: [PATCH] fix(valibot): add isoTime support for time format --- packages/openapi-ts-tests/main/test/cli.test.ts | 7 +++++-- packages/openapi-ts/src/plugins/valibot/index.ts | 1 + packages/openapi-ts/src/plugins/valibot/v1/index.ts | 3 +++ .../openapi-ts/src/plugins/valibot/v1/toAst/string.ts | 11 ++++++++++- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 packages/openapi-ts/src/plugins/valibot/v1/index.ts diff --git a/packages/openapi-ts-tests/main/test/cli.test.ts b/packages/openapi-ts-tests/main/test/cli.test.ts index 6d35d90cb2..9c7b10284a 100755 --- a/packages/openapi-ts-tests/main/test/cli.test.ts +++ b/packages/openapi-ts-tests/main/test/cli.test.ts @@ -1,13 +1,15 @@ import path from 'node:path'; import { sync } from 'cross-spawn'; -import { describe, expect, it } from 'vitest'; +import { beforeAll,describe, expect, it } from 'vitest'; import { getSpecsPath } from '../../utils'; const specs = getSpecsPath(); describe('bin', () => { + beforeAll(() => {}); + it('openapi-ts works', () => { const result = sync('openapi-ts', [ '--input', @@ -17,7 +19,8 @@ describe('bin', () => { '--dry-run', 'true', ]); + expect(result.error).toBeFalsy(); expect(result.status).toBe(0); - }); + }, 60000); }); diff --git a/packages/openapi-ts/src/plugins/valibot/index.ts b/packages/openapi-ts/src/plugins/valibot/index.ts index 7740754d8a..04274e1734 100644 --- a/packages/openapi-ts/src/plugins/valibot/index.ts +++ b/packages/openapi-ts/src/plugins/valibot/index.ts @@ -1,2 +1,3 @@ export { defaultConfig, defineConfig } from './config'; export type { ValibotPlugin } from './types'; +export * as v1 from './v1'; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/index.ts b/packages/openapi-ts/src/plugins/valibot/v1/index.ts new file mode 100644 index 0000000000..075453cd26 --- /dev/null +++ b/packages/openapi-ts/src/plugins/valibot/v1/index.ts @@ -0,0 +1,3 @@ +export * from './constants'; +export * from './plugin'; +export * as toAst from './toAst'; diff --git a/packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts b/packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts index cc7e46edbf..783eaa1e23 100644 --- a/packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts +++ b/packages/openapi-ts/src/plugins/valibot/v1/toAst/string.ts @@ -61,6 +61,16 @@ export const stringToAst = ({ }), ); break; + case 'time': + pipes.push( + tsc.callExpression({ + functionName: tsc.propertyAccessExpression({ + expression: v.placeholder, + name: identifiers.actions.isoTime, // ✅ FIXED HERE + }), + }), + ); + break; case 'ipv4': case 'ipv6': pipes.push( @@ -83,7 +93,6 @@ export const stringToAst = ({ ); break; case 'email': - case 'time': case 'uuid': pipes.push( tsc.callExpression({