[英]Nestjs how to make extend partialtype(createDto) make nested properties of dtos inside createDto also optional
[英]NestJS Open API nested DTOs and PartialType
我有這樣的設置:
export class RequestDTO {
@ApiProperty()
mainObj: MainObjDTO;
}
export class MainObjDTO {
@ApiProperty()
latLong: LatLongDTO
}
export class LatLongDTO {
@ApiProperty()
lat: string;
@ApiProperty()
long: string;
}
更新 MainObj 時,我有類似的東西:
class PartialMainObjDTO extends PartialType(
MainObjDTO,
) {}
export class UpdateRequestDTO {
@ApiProperty()
mainObj: PartialMainObjDTO;
}
問題是latLong
在更新期間仍被標記為必需。
是否有可能以某種方式擁有一個“深”的 PartialType?
您的PartialType
是從@nestjs/swagger
導入的嗎?
import { PartialType } from '@nestjs/swagger'
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.