0% found this document useful (0 votes)
18 views1 page

Swagger Documentation

Swagger is an open framework for designing, documenting, and testing APIs, offering a user-friendly interface for developers. It includes tools like Swagger Codegen, Swagger Editor, and Swagger UI for generating server stubs, designing APIs, and visualizing specifications. The document also provides installation instructions for necessary packages and a sample configuration for integrating Swagger with a Node.js project using MongoDB.

Uploaded by

pkala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views1 page

Swagger Documentation

Swagger is an open framework for designing, documenting, and testing APIs, offering a user-friendly interface for developers. It includes tools like Swagger Codegen, Swagger Editor, and Swagger UI for generating server stubs, designing APIs, and visualizing specifications. The document also provides installation instructions for necessary packages and a sample configuration for integrating Swagger with a Node.js project using MongoDB.

Uploaded by

pkala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Swagger Documentation

1. Open framework.
2. Used for designing, documenting, and testing API
3. User-friendly interface for the developers to interact with the API
4. In Postman few things need to be entered manually, but here it's not.
5. Reference URL -> https://swagger.io/
6. Swagger Codegen, Swagger Editor, and Swagger UI are open-source tools.

Swagger Codegen - Generate server stubs and client SDKs from OpenAPI Specification
definitions.

Swagger Editor – API editor for designing APIS with the OpenAPI and AsyncAPI specifications.

Swagger UI – Visualize OpenAPI specification definitions in an interactive UI.

1. npm install swagger-jsdoc@6.0.0 -- save


it will be saved in package.json also.
2. npm install swagger-ui-express --save
3. npm install swagger-autogen -- save

Create the definitions so we need to import below files in mongoodb.js,

Const swaggerJSDoc = require (‘swagger-jsdoc’)


Const swagger/ui = require (‘swagger-ui-express’)

Const options ={
Definition: {
Openapi: ‘3.0.0’,
Info : {
title : ‘node js api project for mongodb’,
Version: ‘1.0.0’
},
Servers:[
{
uri: ‘http://localhost:8000/’
}
]
},
apis :[ ‘./mongodb.js’ ] i.e, ‘ list of api listed filename need to be given’
}

const swaggerSpec = swaggerJSDoc(options)

app.use( ‘/api-docs’, swagerUi.serve, swaggerUi.setup(swaggerSpec))

You might also like