@geut/fastify-response-validation
v1.0.0
Published
A simple plugin that enables response validation for Fastify.
Downloads
6
Readme
fastify-response-validation
A simple plugin that enables response validation for Fastify.
Install
$ npm install --save-dev @geut/fastify-response-validation
Usage
import fastify from 'fastify'
const app = fastify()
await app.register(import('@geut/fastify-response-validation'))
app.route({
method: 'GET',
path: '/',
schema: {
response: {
'2xx': {
type: 'object',
properties: {
answer: { type: 'string', format: 'date' }
}
}
}
},
handler: async (req, reply) => {
return { answer: 'wrong date' }
}
})
app.inject({
method: 'GET',
path: '/'
}, (err, res) => {
if (err) throw err
// {"statusCode":500,"error":"Internal Server Error","message":"response/answer must match format \"date\""}
console.log(res.payload)
})
Issues
:bug: If you found an issue we encourage you to report it on github. Please specify your OS and the actions to reproduce it.
Contributing
:busts_in_silhouette: Ideas and contributions to the project are welcome. You must follow this guideline.
License
MIT © A GEUT project