Skip to content

Request and response validator against OpenAPI Specification 3

License

Notifications You must be signed in to change notification settings

FutureAdLabs/oas3-chow-chow

 
 

Repository files navigation

oas3-chow-chow

Request and response validator against OpenAPI Specification

Build Status npm

Notes

If you are looking for framework specific middleware, you might want to look at following libraries that use oas3-chow-chow under the hood.

koa-oas3

Installation

$ yarn add oas3-chow-chow
$ # Or
$ npm i oas3-chow-chow

Usage

import ChowChow from "oas3-chow-chow";
import * as fs from "fs";
import * as yaml from "js-yaml";

var doc = yaml.safeLoad(fs.readFileSync("./openapi.yml", "utf8"));
const chow = new ChowChow(doc);

chow.validateRequest("./books", {
  method: "post",
  query: {
    expand: ["document", "author"]
  },
  body: {
    name: "a nice book",
    author: "me me me"
  }
});

chow.validateResponse("./books", {
  method: "post",
  header: {
    "content-type": "application/json"
  },
  body: {
    name: "a nice book",
    author: "me me me"
  }
});

About

Request and response validator against OpenAPI Specification 3

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%