nestjs / swagger

OpenAPI (Swagger) module for Nest framework (node.js) :earth_americas:

Home Page:https://nestjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

DTO doesn't inherit all properties using mapped-types [SWC]

tuxmachine opened this issue · comments

Is there an existing issue for this?

  • I have searched the existing issues

Current behavior

Any DTO that inherits from a base-class using the mapped-types is not publishing it's inherited properties in the generated OpenAPI spec when using SWC. (At least in monorepo mode)

Minimum reproduction code

tuxmachine/nestjs-library#4

Steps to reproduce

  • Inherit from another DTO using the mapped-types: import { PickType } from '@nestjs/swagger';
  • Generate an openapi spec
  • Only inherited properties that are decorated with @ApiProperty are visible on the target DTO, but even those lack other available metadata that could be inferred when the property was inherited w/o mapped-types or was directly available on the target DTO

Expected behavior

All inherited properties with all available metadata are published in the OpenAPI spec

Package version

7.1.1

NestJS version

10.1.0

Node.js version

16.19.0

In which operating systems have you tested?

  • macOS
  • Windows
  • Linux

Other

Seems like this is the same bug encountered by @SpeedySH and @mhadi512 #2493 (comment)

Fixed in v7.1.2 ✅

@kamilmysliwiec Thank you very much for the fix.
I have a question and sorry for asking here, but I don't know where to ask, because I couldn't find an answer on the web.
When I run the build command, a file with name "metadata.ts" is generated. Should I commit or ignore this file?

You can safely commit this file @mhadi512