#Using PartialType but don't see the request body in swagger docs

3 messages · Page 1 of 1 (latest)

pulsar valve
#

I'm using PartialType to extend a DTO as follows:

import { PartialType } from '@nestjs/mapped-types';
import { CreateUserRequestDto } from './create-user.request.dto';

export class UpdateUserRequestDto extends PartialType(CreateUserRequestDto) {}

and then I specify it as the body type in the controller method:

update(@Param('id') id: string, @Body() updateUserDto: UpdateUserRequestDto) {
  return this.usersService.update(+id, updateUserDto);
}

but in the swagger docs, i don't see the request body (see attached image)

however if I use "CreateUserRequestDto" instead of "UpdateUserRequestDto" the request body does show up in the swagger docs.

it's worth mentioning that i'm using the "@nestjs/swagger" plugin, although not sure if that makes a difference

astral gate
#

do
import { PartialType } from '@nestjs/swagger';

pulsar valve
#

amazing, that did it, thank you!