Mapped types and other features — OpenAPI · NestJS

Derive the update, birthday and intake DTOs from CreateCatDto with the mapped types from @nestjs/swagger, so the document and the validation follow one definition; keep an internal column and a staff-only route out of the document; and serve the shelter's internal routes as a second specification of their own.

What you will learn

Read the theory for Mapped types and other features

All OpenAPI lessons

All NestJS courses

loading types…

What you'll learn

  • Derive DTOs with PartialType, PickType, OmitType and IntersectionType from @nestjs/swagger, which carry both the document's and class-validator's metadata, and compose them
  • Keep a property out of a schema with @ApiHideProperty and a route out of the document with @ApiExcludeEndpoint (or a controller with @ApiExcludeController), while the app keeps serving them
  • Serve more than one specification from one app with createDocument's include option and a second setup path
  • Say what the Nest CLI's Swagger plugin would add at build time, and why this browser, like ts-jest or plain tsc, compiles without it