Types and parameters — OpenAPI · NestJS

Make the document say what the API really accepts: examples, bounds and defaults on each property, an enum with a schema of its own, an optional query parameter with allowed values, a described path parameter, and a request body that is an array of DTOs.

What you will learn

Read the theory for Types and parameters

All OpenAPI lessons

All NestJS courses

loading types…

What you'll learn

  • Put Schema Object keywords (description, example, minimum, default) on a property with @ApiProperty's options, and rename or describe a schema with @ApiSchema
  • Document an enum, and give it a schema of its own with enumName so generated clients share one type
  • Describe an array property with type: [String], and an array body with @ApiBody, because TypeScript keeps no metadata for either
  • Describe query and path parameters beyond what the scanner infers, with @ApiQuery and @ApiParam