Swagger CLI plugin

A plugin to aid in detecting the data to be documented.

What happens is that TypeScript's metadata reflection system has several limitations, which prevents automatic detection of this data. Fortunately, we can activate the Swagger CLI plugin, which fixes many of these issues. The main advantage is that it avoids the necessity of flooding the codebase with swagger decorators for it to detect the data we want to document.

This official NestJS doc lists the plugin's features.

To enable it, go to the file nest-cli.json at the root of the project and insert in the compilerOptions

"plugins": ["@nestjs/swagger"]

For the plugin to load properly, the application should be shut down and started again.

After this, we can then refresh the Swagger UI page to see the changes. Now, in the route to create a user, we can see that all the fields required to do so have been automatically detected and shown. However, if you look at the route to update a user, you'll notice that the same has not happened, but fixing this is quite easy.

Commit - Enabling swagger cli plugin

Last updated