Detecting optional fields
In this case, an optional decorator is not enough.
The first thing is that it cannot automatically detect optional fields just due to the @IsOptional()
decorator. If you look at the route to create a product, you'll notice that the description
field appears as required. Fixing this is quite simple, we just need to use the ?
operator next to the field in the DTO. This is what the field would look like:
We can then search for @IsOptional
and do the same with all the fields marked with this decorator.
Commit - Marking optional fields for swagger
Last updated