swagger-param-sanitizer
v1.0.6
Published
Takes in raw string params from requests and parses them into the correct types according to the swagger doc
Downloads
2
Readme
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)
})