orval icon indicating copy to clipboard operation
orval copied to clipboard

[Feature] Allow to customize data type for dates

Open rcomesan opened this issue 1 year ago • 2 comments

What are the steps to reproduce this issue?

Set useDates to true in the output configuration:

module.exports = {
  petstore: {
    output: {
      override: {
        useDates: true,
      },
    },
  },
};

What happens?

It generates TypeScript interfaces using the standard Date data type when the schema format is 'date' or 'date-time'.

What were you expecting to happen?

I was expecting to have a way to customize the data type used here. I have a custom class that I use for dates and I'd like to import it and use that instead of the standard Date object.

I know I must handle date parsing/construction myself, but even if I do this the interfaces are defined with Date instead of my custom DateTime class.

Any other comments?

Is there a way to achieve this? If not, is there any interest in such a feature?

rcomesan avatar Jun 04 '24 02:06 rcomesan

I am interested in this feature. A similar, useful, feature would be to have separate types for OpenAPI date and date-time string formats.

sloane avatar Jun 18 '24 04:06 sloane

I was just trying to find a workaround for this as well but couldn't find any.

The doc claims "You can choose to use any Date library you want", but unless you can specify the client to use that library's type it wouldn't really be usable as the type signature would remain incorrect.

SaebAmini avatar Aug 22 '24 01:08 SaebAmini

Closed in favor of #1939

melloware avatar Feb 25 '25 12:02 melloware