Giter Club home page Giter Club logo

koa-oai-router-correction's Introduction

Koa-OAI-Router-Correction

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

Request form correction plugin for koa-oai-router.

Installation

npm i koa-oai-router-correction --save

Info

field type info
name string correction
evoked fields string parameters
evoked value object OpenApi parameter object
options object collectionFormat

Usage

collectionFormat

Determines the format of the array if type array is used. Possible values are:

  • csv - comma separated values foo,bar.
  • ssv - space separated values foo bar.
  • tsv - tab separated values foo\tbar.
  • pipes - pipe separated values foo|bar.
  • multi - corresponds to multiple parameter instances instead of multiple values for a single instance foo=bar&foo=baz. This is valid only for parameters in "query" or "formData".

Simple code:

const Koa = require('koa');
const Router = require('koa-oai-router');
const middlewareLoader = require('koa-oai-router-middleware');
const correctionHandler = require('koa-oai-router-correction');

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

router.moount();

router.mount(middlewareLoader('./controllers'));
router.mount(correctionHandler({collectionFormat: true}));

app.use(bodyParser());
app.use(router.routes());
> curl -X GET http://localhost:3000/api/pets?tags=a,b,c
> {tags: ["a", "b", "c"]}
>
> curl -X GET http://localhost:3000/api/pets?tags=a|b|c
> {tags: ["a", "b", "c"]}
>
> curl -X GET http://localhost:3000/api/pets?tags=a b c
> {tags: ["a", "b", "c"]}
>
> curl -X GET http://localhost:3000/api/pets?tags=a\b\c
> {tags: ["a", "b", "c"]}

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.