Closed javierguzman closed 11 months ago
@javierguzman Did you read the section about deserialization in the README ? Your use-case is exactly the example provided in it: https://github.com/ThomasAribart/json-schema-to-ts#deserialization
You miss a deserialize
option in FromSchema
:
export type LayerResponse = FromSchema<
typeof layerResponseSchema,
{
deserialize: [
{
pattern: {
type: 'string';
format: 'date-time';
};
output: Date;
},
];
}
>;
Hello all,
I have these two schemas:
Then, I generate the response type like this:
export type LayerResponse = FromSchema<typeof layerResponseSchema>;
And now if I create a LayerResponse object, Typescript complains because foundLayer.created_at is Date, while createdAt is string:
I saw #26 and I thought my example would work. Is this a bug or am I missing something along the way?
Thank you in advance and regards