NestJS Open API nested DTOs and PartialType

Viewed 37

I have a setup like this:

export class RequestDTO {
  @ApiProperty()
  mainObj: MainObjDTO;
}

export class MainObjDTO {
  @ApiProperty()
  latLong: LatLongDTO
}

export class LatLongDTO {
  @ApiProperty()
  lat: string;

  @ApiProperty()
  long: string;  
}

When updating MainObj I have something like:

class PartialMainObjDTO extends PartialType(
  MainObjDTO,
) {}

export class UpdateRequestDTO {
  @ApiProperty()
  mainObj: PartialMainObjDTO;
}

The problem is that latLong is still marked as required during Update.

Is it possible to have a 'deep' PartialType somehow?

1 Answers
Related