Skip to content
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

Zod: Add Configurable Option to Include { offset: true } in Zod Datetime Generation #1669

Open
OH2015 opened this issue Oct 22, 2024 · 1 comment
Labels
zod Zod related issue

Comments

@OH2015
Copy link

OH2015 commented Oct 22, 2024

What are the steps to reproduce this issue?

1.Generate Zod schemas using Orval with an OpenAPI specification.
2.Observe the generated schema for datetime fields.
3.Notice that datetime fields are defined as datetime() without { offset: true }.

What happens?

The generated Zod schemas have datetime fields defined as datetime() by default, which does not include the { offset: true } option.

What were you expecting to happen?

I expected the generated Zod schemas to include an option to automatically set { offset: true } for datetime fields based on configuration, allowing for proper handling of date-time values without manual modifications.

Any logs, error output, etc?

No specific error output, but the lack of { offset: true } in the datetime definitions leads to potential issues in date handling.
For example, when receiving data like "2024-01-01T00:00:00+09:00", the generated Zod schema cannot correctly interpret the timezone offset, which may result in incorrect date handling in the application.

What versions are you using?

System:
OS: Windows 11 10.0.22631
CPU: (12) x64 13th Gen Intel(R) Core(TM) i5-1335U
Memory: 3.58 GB / 15.69 GB
npmPackages:
@tanstack/react-query: ^5.49.2 => 5.49.2
axios: ^1.7.2 => 1.7.4
msw: ^2.3.1 => 2.4.11
orval: ^7.1.1 => 7.1.1
react: ^18.3.1 => 18.3.1
zod: ^3.23.8 => 3.23.8

@melloware melloware added the zod Zod related issue label Oct 22, 2024
@melloware
Copy link
Collaborator

PR is welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
zod Zod related issue
Projects
None yet
Development

No branches or pull requests

2 participants