swagger-param-sanitizer

1.0.6 • Public • Published

swaggerParamSanitizer

Params are passed in as strings in express, and this middleware converts them into the ints, booleans, etc. that they should be, as defined in the swagger doc.

Example usage:

const swagger = require('./my-swagger.json')
const sanitizer=require('swagger-param-sanitizer')(swagger)
const express = require('express')
const app = express()
app.post('/api/doSomething',sanitizer,(req,res)=>{
console.log('these should have the proper types now:')
console.log(req.params)
console.log(req.query)
console.log(req.body)
})

Readme

Keywords

none

Package Sidebar

Install

npm i swagger-param-sanitizer

Weekly Downloads

1

Version

1.0.6

License

MIT

Unpacked Size

5.54 kB

Total Files

4

Last publish

Collaborators

  • andrewulrich