Closed stalniy closed 2 years ago
Never mind. I decided to go with custom solution
I still think it could be an interesting feature. json-schema-to-ts
would definitely benefit from handling custom deserialization.
However, it would not be a simple road. I reopen the PR add it and as a milestone.
+1. Also wants this feature to use it with mongodb.
+1. We have quite a few places in our code base that would benefit of proper Date handling. How would you recommend going about this for the time being?
@isakstarlander @leoblum @stalnyi Alright, it seems this feature is the next on the list :) I'll try to implement it by the end of this month.
For the moment, there's not better way than replacing by hand the property type from the parsed result, for instance with ts-toolbelt
Update
utility: https://millsp.github.io/ts-toolbelt/modules/object_p_update.html
@stalniy @leoblum @isakstarlander It took some time but the feature is now available in v2.3.0 ✨ (done in https://github.com/ThomasAribart/json-schema-to-ts/pull/64)
See an example in the README: https://github.com/ThomasAribart/json-schema-to-ts#deserialization
JSONSchema supports
format
ontype = string
and formatdate-time
I wantFromSchema
to returnDate
object instead of string.There may be other custom formats like
object-id
(MongoDB special type), so what I suggest is to allow users to specify mapping of format value to some scalar type: