Skip to content

Optional flag which changes string to date in case of format data-time or date #396

Open
@NicoVogel

Description

@NicoVogel

In the project I am working on, we use openapi v3.
The schema contains objects which use the type string with the format date-time.

example:

ExampleType:
  title: ExampleType
  type: object
  properties:
    id:
      type: integer
    validFrom:
      type: string
      format: date-time
      example: "2012-10-27T17:18:30.966Z"

We did not want to convert the date everytime and therefore we created a middleware for the server and client-side that automatically converts it from string to Date.
When creating the models via the openapi-typescript-gencode tool, the output models use the type string (as intended).
But in our case we need it to be of type Date, which is a special case.
Therefore an optional flag to enable this feature would be great.

What is needed?

It needs to remember the format value and in case of date or date-time the output type should be Date instead of string.

About implementing it

I would try to implement it and in case that anyone wants to help me, that would be great.

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions