express-openapi3.0-generator
v1.0.1
Published
It is a tiny package to generate API documentation in swagger using JS file with the help of "swagger-ui-express"
Downloads
1
Readme
express-openAPI-generator
ABOUT THE PROJECT
It is a tiny package to generate API documentation in swagger using JS file with the help of "swagger-ui-express"
Document
- Install
npm i express-openapi3.0-generator swagger-ui-express
- Create /api-doc as mentioned in swagger-ui-express package
const router = require('express').Router();
const swaggerUi = require('swagger-ui-express');
const {document} = require('./swagger.js')
const swaggerDocument = require(document);
router.use('/api-docs', swaggerUi.serve);
router.get('/api-docs', swaggerUi.setup(swaggerDocument));
- Create swagger.js file
const { AutoDoc } = require('express-openapi3.0-generator')
const doc = new AutoDoc()
doc.init({
title: "test",
servers: ["http://127.0.0.1:8000"]
})
doc.endPoints([
{
url: "/login",
get: {
tag: "tag",
description: "somthing",
summary: "summary",
body: {
phoneNumber: {
description: "body",
required: true,
}
},
path: {
id: {
description: "id",
required: true
}
},
query: {
test: {
description: "test",
required: false
}
},
responses: {
200: {
description: "OK",
response: {
sucess: true,
message: "yesss",
data: doc.schema(AdminSchema) // express schema to openAPI schema
}
}
}
},
}
])
module.exports.document = doc.render()
Roadmap
See the open issues for a list of proposed features (and known issues).
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request