@earnd/swagger-middleware
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

swagger-middleware

This is an express middleware which generates express routes and validates requests based on a swagger definition.

Motivation

There are many swagger middlewares out there (e.g. swagger-routes-express, swagger-express-middleware) but we found none of them offered the functionality we needed in a single package:

  • generate routes and link them with handlers
  • validate requests
  • create uniform errors
  • support async handlers

Dependencies

  • Express 4.0
  • TypeScript

Installation

npm install -S @earnd/swagger-middleware

Example

import swagger from '@earnd/swagger-middleware';
import express, { Request, Response } from 'express';

app = express();
api = {
listPets: (req: Request, res: Response) => res.end()
};

app.use(swagger('./petstore.yaml', api));

Package Sidebar

Install

npm i @earnd/swagger-middleware

Weekly Downloads

4

Version

0.0.4

License

MIT

Unpacked Size

22.7 kB

Total Files

15

Last publish

Collaborators

  • rodrigofeijaoearnd
  • igoratron
  • freeup