簡體   English   中英

NestJS 打開 API 嵌套 DTO 和 PartialType

[英]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導入的嗎?

@Nestjs/swagger 映射類型

import { PartialType } from '@nestjs/swagger'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM