diff --git a/.changeset/odd-yaks-love.md b/.changeset/odd-yaks-love.md new file mode 100644 index 000000000..0926d4665 --- /dev/null +++ b/.changeset/odd-yaks-love.md @@ -0,0 +1,5 @@ +--- +"@hey-api/openapi-ts": patch +--- + +fix(valibot): use `isoTimestamp` instead of `isoDateTime` for date-time format diff --git a/packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts index ea4d8d500..64359ac22 100644 --- a/packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts @@ -365,7 +365,7 @@ export const vModelWithPattern = v.object({ key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), name: v.pipe(v.string(), v.maxLength(255)), enabled: v.optional(v.pipe(v.boolean(), v.readonly())), - modified: v.optional(v.pipe(v.pipe(v.string(), v.isoDateTime()), v.readonly())), + modified: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), diff --git a/packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts index 4715a60ef..060674cc3 100644 --- a/packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/test/__snapshots__/3.0.x/plugins/valibot/default/valibot.gen.ts @@ -691,7 +691,7 @@ export const vModelWithPattern = v.object({ key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), name: v.pipe(v.string(), v.maxLength(255)), enabled: v.optional(v.pipe(v.boolean(), v.readonly())), - modified: v.optional(v.pipe(v.pipe(v.string(), v.isoDateTime()), v.readonly())), + modified: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), @@ -701,8 +701,8 @@ export const vModelWithPattern = v.object({ export const vFile = v.object({ id: v.optional(v.pipe(v.pipe(v.string(), v.minLength(1)), v.readonly())), - updated_at: v.optional(v.pipe(v.pipe(v.string(), v.isoDateTime()), v.readonly())), - created_at: v.optional(v.pipe(v.pipe(v.string(), v.isoDateTime()), v.readonly())), + updated_at: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), + created_at: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), mime: v.pipe(v.string(), v.minLength(1), v.maxLength(24)), file: v.optional(v.pipe(v.pipe(v.string(), v.url()), v.readonly())) }); @@ -816,15 +816,15 @@ export const vModelWithOneOfEnum = v.union([ ]) }), v.object({ - content: v.pipe(v.string(), v.isoDateTime()), + content: v.pipe(v.string(), v.isoTimestamp()), foo: v.picklist([ 'Quux' ]) }), v.object({ content: v.tuple([ - v.pipe(v.string(), v.isoDateTime()), - v.pipe(v.string(), v.isoDateTime()) + v.pipe(v.string(), v.isoTimestamp()), + v.pipe(v.string(), v.isoTimestamp()) ]), foo: v.picklist([ 'Corge' diff --git a/packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts b/packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts index 2af8502dc..7b6038462 100644 --- a/packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts +++ b/packages/openapi-ts-tests/test/__snapshots__/3.1.x/plugins/valibot/default/valibot.gen.ts @@ -686,7 +686,7 @@ export const vModelWithPattern = v.object({ key: v.pipe(v.string(), v.maxLength(64), v.regex(/^[a-zA-Z0-9_]*$/)), name: v.pipe(v.string(), v.maxLength(255)), enabled: v.optional(v.pipe(v.boolean(), v.readonly())), - modified: v.optional(v.pipe(v.pipe(v.string(), v.isoDateTime()), v.readonly())), + modified: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), id: v.optional(v.pipe(v.string(), v.regex(/^\d{2}-\d{3}-\d{4}$/))), text: v.optional(v.pipe(v.string(), v.regex(/^\w+$/))), patternWithSingleQuotes: v.optional(v.pipe(v.string(), v.regex(/^[a-zA-Z0-9']*$/))), @@ -696,8 +696,8 @@ export const vModelWithPattern = v.object({ export const vFile = v.object({ id: v.optional(v.pipe(v.pipe(v.string(), v.minLength(1)), v.readonly())), - updated_at: v.optional(v.pipe(v.pipe(v.string(), v.isoDateTime()), v.readonly())), - created_at: v.optional(v.pipe(v.pipe(v.string(), v.isoDateTime()), v.readonly())), + updated_at: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), + created_at: v.optional(v.pipe(v.pipe(v.string(), v.isoTimestamp()), v.readonly())), mime: v.pipe(v.string(), v.minLength(1), v.maxLength(24)), file: v.optional(v.pipe(v.pipe(v.string(), v.url()), v.readonly())) }); @@ -807,14 +807,14 @@ export const vModelWithOneOfEnum = v.union([ ]) }), v.object({ - content: v.pipe(v.string(), v.isoDateTime()), + content: v.pipe(v.string(), v.isoTimestamp()), foo: v.picklist([ 'Quux' ]) }), v.object({ content: v.tuple([ - v.pipe(v.string(), v.isoDateTime()), + v.pipe(v.string(), v.isoTimestamp()), v.string() ]), foo: v.picklist([ diff --git a/packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts b/packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts index 735206c81..1b6474b87 100644 --- a/packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts +++ b/packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators-metadata/valibot.gen.ts @@ -54,6 +54,6 @@ export const vPatchFooParameterBaz = v.object({ export const vPatchFooParameterQux = v.pipe(v.string(), v.isoDate()); -export const vPatchFooParameterQuux = v.pipe(v.string(), v.isoDateTime()); +export const vPatchFooParameterQuux = v.pipe(v.string(), v.isoTimestamp()); export const vPostFooData = vFoo3; \ No newline at end of file diff --git a/packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators/valibot.gen.ts b/packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators/valibot.gen.ts index 735206c81..1b6474b87 100644 --- a/packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators/valibot.gen.ts +++ b/packages/openapi-ts-tests/test/__snapshots__/3.1.x/validators/valibot.gen.ts @@ -54,6 +54,6 @@ export const vPatchFooParameterBaz = v.object({ export const vPatchFooParameterQux = v.pipe(v.string(), v.isoDate()); -export const vPatchFooParameterQuux = v.pipe(v.string(), v.isoDateTime()); +export const vPatchFooParameterQuux = v.pipe(v.string(), v.isoTimestamp()); export const vPostFooData = vFoo3; \ No newline at end of file diff --git a/packages/openapi-ts/src/plugins/valibot/plugin.ts b/packages/openapi-ts/src/plugins/valibot/plugin.ts index fa63a718e..1f0cd6a92 100644 --- a/packages/openapi-ts/src/plugins/valibot/plugin.ts +++ b/packages/openapi-ts/src/plugins/valibot/plugin.ts @@ -542,7 +542,7 @@ const stringTypeToValibotSchema = ({ compiler.callExpression({ functionName: compiler.propertyAccessExpression({ expression: identifiers.v, - name: identifiers.actions.isoDateTime, + name: identifiers.actions.isoTimestamp, }), }), );