How to use swagger in our express app ?
Swagger is an open-source framework that enables developers to design, document, and consume Restful APIs effortlessly.
The directory structure of project
We will use some steps
Step 1: install "swagger-ui-express" and "yamljs" package in apps by use command
npm install swagger-ui-express yamljs
step 2 : we will include some configuration in our index.js file. Use green bold configuration in index.js
Step 3: Create swagger.yaml file in root directory .
In yaml we write swagger instruction for API. I write here for about Api which use CRUD operations.
Step 4: open localhost:9000/api-docs/ to view swagger UI
I used below for reference https://swagger.io/