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

[Feature] Improve date handling with useDates #1939

Open
mbwestphal opened this issue Feb 25, 2025 · 3 comments
Open

[Feature] Improve date handling with useDates #1939

mbwestphal opened this issue Feb 25, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@mbwestphal
Copy link

When you enable the useDates option you yourself are responsible for finding dates in response objects and processing them accordingly.

The documentation recommends the use of a Regexp.

This is incredibly error prone because users might insert strings that look like dates anywhere such as in the user name field upon registration.

You could also generate zod validations and use those to parse the dates. However that is a manual process. Orval does not produce information that allows me to automatically associate an API client function with a validation function at runtime.

What Is to Be Done?

Orval should provide a function for every request schema and a function for every response schema that will transform dates according to what is declared in the schema.

Later we could allow users to customize these functions in order to use a third party date library or to automatically process altogether custom types.

@melloware
Copy link
Collaborator

I think this is a duplicate of this request: #1432

@melloware melloware added the duplicate This issue or pull request already exists label Feb 25, 2025
@mbwestphal
Copy link
Author

I thought so too, but #1432 just aims to make the type definition of a date configurable. That is, change it from string or Date to SomeThirdPartyDate in the type definitions.

@melloware melloware added enhancement New feature or request and removed duplicate This issue or pull request already exists labels Feb 25, 2025
@melloware
Copy link
Collaborator

OK marked as enhancement and will close that other ticket and point them here.

@melloware melloware changed the title Handle dates correctly Handle dates correctly with useDates Feb 25, 2025
@melloware melloware changed the title Handle dates correctly with useDates [Feature] Improve date handling with useDates Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants