I create @ApiProperty() in Dto like this
export class UpdateMeassageDto {
@ApiProperty()
message: {
hash: string;
created_at: Date;
updated_at: Date;
}
}
Then it got an empty result like this
I create @ApiProperty() in Dto like this
export class UpdateMeassageDto {
@ApiProperty()
message: {
hash: string;
created_at: Date;
updated_at: Date;
}
}
Then it got an empty result like this
try to define a new type as:
export class Message{
@ApiProperty()
hash: string;
@ApiProperty()
created_at: Date;
@ApiProperty()
updated_at: Date;
}
and update your DTO as follow:
export class UpdateMessageDto {
@ApiProperty()
message: Message
}
You can do it in the following way
import { ApiProperty, getSchemaPath } from '@nestjs/swagger';
export class MessageDto {
@ApiProperty({
type: 'string',
example: 'hx1231',
})
hash: string;
@ApiProperty({
type: 'date',
example: '2021-08-04T19:39:00.829Z',
})
created_at: Date;
@ApiProperty({
type: 'string',
format: 'date-time',
example: '2021-08-04T19:39:00.829Z',
})
updated_at: Date;
}
export class UpdateMessageDto {
@ApiProperty({
type: 'array',
items: { $ref: getSchemaPath(MessageDto) },
})
message: MessageDto;
}
ApiProperty is needed for each property. You can use $ref to use one DTO in another DTO. It will be good to use also class-validator in the DTOs.