I have a response object that looks like this
class MyResponse {
id: string;
qty: number;
paid: Date;
}
My controller looks like
@Get("/test")
async test(): Promise<MyResponse> {
const res: MyResponse = {
id: 'hi',
qty: 1,
paid: new Date(),
}
return res;
}
In my swagger and in my unit test however, my responses look like
{
id: 'hi',
qty: 1,
paid: 'string-ified version'
}
The qty is coming across as a number but why is the date coming across as not a Date object? Why is it a string? I'm asking because I can't get my e2e test to pass because of the type mis-match. I would really prefer it to be of type Date and not string anyway. Is there a way to force nest to serialize it properly? I've tried adding a ValidationPipe to that endpoint as well as having an @Transform on my paid field.