orval-labs / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
2.98k stars 327 forks source link

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

Open OH2015 opened 6 days ago

OH2015 commented 6 days ago

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 commented 6 days ago

PR is welcome!