Hello guys I am trying to swagger my endpoints which has nested data
For example this is what my response look
{
"message": "Request successful",
"data": {
"(user or users or cart etc.)":"array or object or whatever"
},
"statusCode": 200
}
so here is how i am handling it
@ApiResponse({ status: HttpStatus.OK, description: 'User fetched successfully', type: IUserResponse })
The type i am assigning is this class
export class IUserResponse extends IResponse {
@ApiProperty({ type: IUserPublic })
data: {
user: IUserPublic;
};
}
the IResponse is this
export class IResponse {
@ApiProperty({ description: 'Response message', example: 'Request successful' })
message: string;
@ApiProperty({ description: 'Response data', example: {}, type: Object })
data: unknown;
@ApiProperty({ description: 'HTTP status code', example: HttpStatus.OK })
statusCode: HttpStatus;
}
So why the response in the swagger looks like this
{
"message": "Request successful",
"data": {},
"statusCode": 200
}
instead of what i specified above