这是indexloc提供的服务,不要输入任何密码
Skip to content

fix(valibot): use v.isoTimestamp instead of v.isoDateTime for OpenAPI's date-time #2192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/odd-yaks-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hey-api/openapi-ts": patch
---

fix(valibot): use `isoTimestamp` instead of `isoDateTime` for date-time format
Original file line number Diff line number Diff line change
Expand Up @@ -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']*$/))),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']*$/))),
Expand All @@ -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()))
});
Expand Down Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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']*$/))),
Expand All @@ -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()))
});
Expand Down Expand Up @@ -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([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
2 changes: 1 addition & 1 deletion packages/openapi-ts/src/plugins/valibot/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@
compiler.callExpression({
functionName: compiler.propertyAccessExpression({
expression: identifiers.v,
name: identifiers.actions.isoDateTime,
name: identifiers.actions.isoTimestamp,

Check warning on line 545 in packages/openapi-ts/src/plugins/valibot/plugin.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/plugins/valibot/plugin.ts#L545

Added line #L545 was not covered by tests
}),
}),
);
Expand Down