Koa-OAI-Router-Responses
Responses validator plugin for koa-oai-router.
Installation
npm i koa-oai-router-responses --save
Info
field | type | info |
---|---|---|
name | string |
responses |
evoked fields | string |
responses |
evoked value | object |
OpenApi responses object |
options | object |
ajv , before , after |
options
{object}
enable
{boolean}
Enable or disable ajv validator.ajv
{object|function}
object
Options of Ajv.function
is a factory with arguments(Ajv)
and must return a ajv instance.before
{function}
Before validte. Having arguments(ctx, {catched, data, validRet, validErrs, endpoint, field, fieldValue, operation, operationValue})
.catched
{boolean}
unexpected error.data
{any}
response body or error.validRet
{boolean}
valid result.validErrs
{[object]}
valid errors.endpoint
{string}
field
{string}
fieldValue
{object}
operation
{string}
operationValue
{object}
after
{function}
After validte.
Simple code:
const Koa = ;const Router = ;const middlewareLoader = ;const responsesHandler = ; const app = ;const router = apiDoc: './api'; router;router; app;app;