How to use swagger in our express app ?
swagger

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

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

index.js

Step 3: Create swagger.yaml file in root directory .

swagger.yaml

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

swaggerUI

I used below for reference https://swagger.io/



要查看或添加评论,请登录

Ajay Kumar的更多文章

  • Why should we use Angular?

    Why should we use Angular?

    Angular is a popular front-end framework that helps developers to build scalable and dynamic web applications.It is…

  • Good Bye nodemon

    Good Bye nodemon

    Nodemon is a tool that is used for automatically restarting a Node.js application whenever there are changes made to…

  • Use full tips for writing JavaScript code.

    Use full tips for writing JavaScript code.

    Use const for variables that don't change,and use let for variable we want to re-assignments of value Use arrow…

  • JavaScript is Everywhere

    JavaScript is Everywhere

    Today, new languages are being created to build a new level of applications that have advanced features and also meet…

社区洞察

其他会员也浏览了