Api decorators
A lot is automated for us, but still some manual work is necessary.
Notice that the login()
route in the Swagger UI lacks information. This is because we could not use the @Body()
decorator in this route, and so Swagger cannot infer we are using the LoginDto
here. Nor does it infer the JWT cookie returned.
We should then go to the AuthController
and, over the login()
route, use the @ApiBody()
decorator to define the expected body.
For the cookie part, we have to use the @ApiResponse()
decorator for the OK status, and then state that it will have the header
Set-Cookie, while defining a proper type
and description
for the cookie
. We can then first define this header
in the file auth -> swagger -> jwt-cookie.header.
And then, use it in the decorator as mentioned.
We have then manually corrected these flaws, and can see the changes now.
Commit - Using swagger decorators to document manually
Last updated