Code Monkey home page Code Monkey logo

koa-oai-router-responses's Introduction

Koa-OAI-Router-Responses

License Node Version NPM Version Build Status Test Coverage Downloads Dependency Status

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 = require('koa');
const Router = require('koa-oai-router');
const middlewareLoader = require('koa-oai-router-middleware');
const responsesHandler = require('koa-oai-router-responses');

const app = new Koa();
const router = new Router({
  apiDoc: './api',
});

router.mount(responsesHandler());
router.mount(middlewareLoader('./controllers'));

app.use(bodyParser());
app.use(router.routes());

koa-oai-router-responses's People

Contributors

amazing-gao avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

koa-oai-router-responses's Issues

README.md 例子错误

router.mount(middlewareLoader('./controllers'));
router.mount(responsesHandler());

to

router.mount(responsesHandler());
router.mount(middlewareLoader('./controllers'));

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.