orval-labs/orval

[Feature] Improve date handling with `useDates`

Fechada

#1.939 aberto em 25 de fev. de 2025

 (9 comentários) (9 reações) (0 responsável)TypeScript (648 forks)auto 404
enhancementhelp wanted

Métricas do repositório

Stars
 (6.272 estrelas)
Métricas de merge de PR
 (Mesclagem média 2d 15h) (73 fundiu PRs em 30d)

Description

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.

Guia do colaborador