Extra module 3 - OpenAPI Specification

Documentation on how to interact with the system.

Imagine the following scenario: there is an online service that collects data of products from different online shops. The intention is that a person accessing this service can then compare these products: which ones are available in each shop, their respective prices, buyer reviews, etc. In a case like this, it would be interesting to expose a documentation of our backend or API, showing how to communicate with it. This way, the creator of this service would know how to obtain this data from us.

There is a standard that defines rules for this kind of documentation: the OpenAPI Specification. It is language-agnostic and states that a documentation like this should contain:

  • Available operations (routes or endpoints)

  • Parameters (what to send & what to be received)

  • Authentication methods

  • Contact information, license, terms of use, and other information

Fortunately, Nest has integration with a popular tool that implements this specification: Swagger. By leveraging it, much of this documenting process will be completely automated, which will save us a lot of work. Let's then install the necessary dependency to start this module.

yarn add @nestjs/swagger

Last updated