Introduction — OpenAPI · NestJS

Generate an OpenAPI document for the shelter's cats API from the code it already has: describe it with a DocumentBuilder, mount the Swagger UI at /api, make the DTO's properties visible to the document, and name each operation after its handler.

What you will learn

Read the theory for Introduction

All OpenAPI lessons

All NestJS courses

loading types…

What you'll learn

  • Explain what an OpenAPI document is, who reads it (people through the Swagger UI, tools through the JSON) and where the Swagger module gets it from
  • Describe an API with DocumentBuilder and mount the document with SwaggerModule.setup, built lazily through a factory
  • Make a DTO's properties appear in its schema with @ApiProperty() and @ApiPropertyOptional(), and read what the document says about them
  • Tune the document with SwaggerDocumentOptions, naming operations with an operationIdFactory