Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable NestJs swagger 4.x plugin

Tags:

nestjs

How do you use the new swagger plugin? I have it in my compiler options:

  "compilerOptions": {
    "plugins": ["@nestjs/swagger/plugin"]
  }

And I am running the application with nest start as described: https://docs.nestjs.com/recipes/swagger#migration-to-40

However, no automated-magic documentation appears to be happening.

like image 524
coler-j Avatar asked Nov 30 '22 13:11

coler-j


1 Answers

It was an issue with global dependencies conflicting with local ones, as well as the old build (set to incremental mode) conflicting with the new property generation. Did the following to resolve the issue:

  • If nest cli is globally installed, manually upgrade it: yarn global upgrade upgrade @nestjs/cli, or with npm (npm update -g @nestjs/cli)
  • Upgrade local service nest to most recent version: nest update
  • Add the following to your nest-cli.json:
  "compilerOptions": {
    "plugins": ["@nestjs/swagger/plugin"]
  }
  • Remove your local dist folder (or do a yarn build)
  • Start the server with the nest cli commands (i.e. nest start or nest start:dev)
like image 167
coler-j Avatar answered Jan 27 '23 00:01

coler-j