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
Zur Übersicht

Mehr vom DevSquad...

Lucas Meurer

hurlurl.com - shortlink load balancer

Dennis Hundertmark

sayhello  👋