6

I have a project with a Nest.js API and an Angular SPA. The DTOs used by the SPA to communicate with the API are in a separate project called Models and I'm using it as a dependency. In that way, I only need to change the DTO in one place, and can reuse them in both projects.

I've been trying to document my API with Swagger using @nestjs/swagger. This lib requires me to use decorators in my DTOs if I want their attributes to be shown in Swagger.

When I do that, everything works as expected in my API, but the Angular SPA breaks because it doesn't has the @nestjs/swagger dependency. Even after installing it as dependency for the app, it still requires me to install @nestjs/common, express, mime, send, etc. and I shouldn't install all of those backend related dependencies to my app just for the sake of documentation.

Do you guys have any idea how to overcome this issue or other tips about documentation generation for APIs with Nest.js?

Miguel Trabajo
  • 437
  • 3
  • 11

0 Answers0