fabien0102 / openapi-codegen

A tool for generating code base on an OpenAPI schema.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handling of date(time)

PeterKottas opened this issue · comments

Given a part of a schema like this:

"createdOn": {
  "type": "string",
  "format": "date-time"
},

this field is generated

/**
   * @format date-time
   */
  createdOn?: string;

While technically correct, it makes one wonder if this should not be internally parsed and saved to the object as Moment/Date/... based on config? If it was just a barebones client, it wouldn't be so bad, problem is if we generate the react-query, it's kinda weird to then have to parse the fetched/chached data. Feels like it should be done one level up. Thoughts?

Would be nice to be able to parse date (without time) separate to date-time and also if a POST/PUT requires a date without time to provide a way to automatically transform from js date object.

Sorry to highjack, but I'm interested in a very related thing.

I would like to convert all properties with type: 'date' into CalendarDate types. Possible?