swagger2-utils

2.0.10 • Public • Published

swagger2-utils

Utilities for validating and working with swagger 2.0 documents in Node.js

Installation

npm install swagger2-utils

Validate

Validates the supplied swagger document object against the official swagger 2.0 schema. Returns a boolean indicating validity.

var swagger2 = require('swagger2-utils');
var swaggerDoc = require('my-swagger-doc.json');

var valid = swagger2.validate(swaggerDoc);

if valid {
  console.log('valid!');
}
else {
  console.log('failed!');
  throw swagger2.validationError
}

Dereference

Returns a new object where all $ref keys are replaced with the value they reference.

var dereferencedDoc = swagger2.dereference(swaggerDoc);

Create Operations List

Creates an array of operation objects. These objects contain the "concrete" operations, meaning they have incorporated the schemes, parameters, custom fields, etc from the root and path-level objects.

var operationsList = swagger2.createOperationsList(swaggerDoc);

Dependencies (3)

Dev Dependencies (8)

Package Sidebar

Install

npm i swagger2-utils

Weekly Downloads

15

Version

2.0.10

License

MIT

Last publish

Collaborators

  • jflitton