Comments introspection
Automatic documentation through comments.
As was already explained before, it is a nice practice to use good naming conventions in order to avoid unnecessary comments. However, it would be adequate to explain that the user password
should follow the rules defined previously. Due to this, let's add a description to it in the CreateUserDto
through a JSDoc, which we are already familiar with.
There are two interesting options available in the Swagger plugin, they are:
classValidatorShim
- class validator decorators are used to enrich the documentationintrospectComments
- descriptions and examples are generated from comments
The first option is enabled by default, but not the second one. So, let's enable it now.
After restarting the application and refreshing the Swagger UI, we can notice the changes.
Commit - Using comment to describe a field in swagger
Last updated