1.0.8 • Published 3 years ago

exp_swagger v1.0.8

Weekly downloads
4
License
ISC
Repository
github
Last release
3 years ago

EXPRESS SWAGGER

Auto generate swagger ui without writing swagger docs.

Installation

Install via npm

npm install exp_swagger

Usage

import express from 'express';
import swagger_ui from 'swagger-ui-express';
import { router, getSwagger } from 'exp_swagger'

// Create Express app instance
const app = express();

// Declare route(s)
router.use(app, '/users')
  .get('/', {
    description: 'Get all users',
    tags: ['Users'],
    input : { header, body, formData, query, params }
  },
    (req, res) => { ... }

// Get autogenerated Swagger
const swagger = getSwagger({
  version : '1.0.0',
  title : 'API docs',
  description : 'This describes all exposed api endpoints',
});

// Serve swagger-ui
app.use("/docs", swagger_ui.serve, swagger_ui.setup(swagger))

// Start server
app.listen(8000)

This will start an Express server with one route and autogenerated Swagger documentation based on the description, tags and input schema.

Remarks

Current support