Skip to content
James Speirs edited this page Oct 9, 2018 · 2 revisions

OpenAPI-Enforcer

Tools for validating and using the Open API Specification (OAS).

Supports OAS 2.0 (formerly Swagger) and OAS 3.x

Features

Installation

npm install openapi-enforcer

Examples

Validate an OAS Definition

const Enforcer = require('openapi-enforcer');

const errors = Enforcer.errors({
  openapi: '3.0.0',
  info: {
    title: "My API"
  }
});

console.log(errors);
// One or more errors exist in the OpenAPI definition
//   at: info
//     Missing required property: version
//   Missing required property: paths

Request and Response

This example shows how to deserialize and validate a request and then how to validate and serialize the response.

const enforcer = Enforcer({
  openapi: '3.0.0',
  info: {
    version: "1.0.0"
    title: "My API"
  },
  paths: {
    "/pet/{petId}": {

    
  }
});
Clone this wiki locally