3.8.2022

Generate Swagger Documentation from Nest API

  1. Add nestjs swagger dependency
$ npm install --save @nestjs/swagger
  1. create Swagger Document and setup
const config = new DocumentBuilder()
    .setTitle(title)
    .setDescription(description)
    .setVersion(version)
    .build();
  const document = SwaggerModule.createDocument(app, config);
  SwaggerModule.setup('api', app, document);
  
  //Swagger Doc is available at: http://localhost:${port}/api
  1. Add Decorators to your Controllers and API Model
  1. See examples and documentation
Simon

Softwareentwickler

Zur Übersicht

Standort Hannover

newcubator GmbH
Bödekerstraße 22
30161 Hannover

Standort Dortmund

newcubator GmbH
Westenhellweg 85-89
44137 Dortmund