Deserializing OpenAPI date and datetimes as JavaScript Date objects
See original GitHub issueI would like to add an option to the library, so that the user can deserialize date and datetime objects (both have type string
and format date
and date-time
, respectively) as JavaScript Date
object.
I have already tested it and this change in scalar.ts
seems to actually be the only change needed (to be added inside the string
case statement):
if(item.format === 'date' || item.format === 'date-time') {
return {
value: 'Date' + nullable,
isEnum: false,
type: 'string',
imports: [],
schemas: [],
};
}
This would only support ISO 8601 dates and date times (default in the OpenAPI specification) but that is what most of the people use in the REST APIs these days.
However, there will also be change needed in the Axios instance, so that dates are properly deserialized as Date
objects (currently these are string
s).
Would you be open for such change? Do you think we should make it optional, via dedicated field in the configuration object?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (8 by maintainers)
Need to be reimplemented since v5. I will do it if you are still interested or someone else?
+1 for this, this is what
openapi-generator
does it makes thenDate
objects.