Member-only story
How to add Swagger UI to an existing Node.js and Express.js project
In this tutorial, we’ll be learning how to add swagger to an existing Node and Express.js. As we already learned in Part 1 — How to create a REST API with Express.js and Node.js (source code Part 1), and now we will add swagger in this project.
Before we start please find below the important definitions:
- Swagger — Swagger is an open-source software framework backed by a large ecosystem of tools that help developers design, build, document, and consume RESTful web services
- Swagger provides a set of great tools for designing APIs and improving the work with web services
a) Swagger Editor — Swagger Editor is an open-source editor to design, define and document RESTful APIs in the Swagger specification.
b) Swagger Codegen — Swagger Codegen is an open-source project which allows the generation of API client libraries (SDK generation), server stubs, and documentation automatically from an OpenAPI Specification.
c) Swagger UI — Swagger UI allows the development team to visualize and interact with the API resources without having any of the implementation logic in place. UI presentation of the APIs is user friendly and easy to understand, with all logic complexity kept behind the screen.
d) Swagger Inspector — A tool for testing and auto-generating OpenAPI documentation for any API. Swagger Inspector allows you to easily validate and test APIs with no limits on what you test. Tests are automatically saved in the cloud with simple access.
3. The OpenAPI Specification, originally known as the Swagger Specification, is a specification for machine-readable interface files for describing, producing, consuming, and visualizing RESTful web services.
In this project, as we already have an existing RESTful API (Part 1 Tutorial) and now Swagger UI will be used only to document the existing API.
Getting Started
- Download the Part 1 source code and open the terminal where you want to save the program
- Run terminal with below command