@smartrecruiters/openapi-schemas-validator

0.3.1 • Public • Published

@smartrecruiters/openapi-schemas-validator

NPM Version NPM Downloads Node.js Version Licence Build

Create schema validators for api documentation in OpenAPI Specification 3.x format.

tv4

This module uses tv4 validator, additionally configured with tv4-formats.

This module uses tv4 validateMultiple function, with checkRecursive param always passed as true.

You can configure tv4 validator with following options:

There is exported an ErrorCodes object containing mappings between error code numbers and error names that are generated by tv4 validator.

OpenAPI Specification 3.0 specific features

Currently @smartrecruiters/openapi-schemas-validator supports nullable field.

Please refer to https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#fixed-fields-20.

License

MIT

API

Modules

@smartrecruiters/openapi-schemas-validator

Classes

SchemaValidator

@smartrecruiters/openapi-schemas-validator

SchemaValidator

Kind: global class

new SchemaValidator(spec, [options])

Create schema validator for schemas defined in spec at #/components/schemas

Param Type Default Description
spec Object API specification in OpenAPI Specification 3.0 format
[options] Object {} options
[options.customFormats] Object custom format validators
[options.banUnknownProperties] boolean false disallow extra properties in validated objects

schemaValidator.validate(entity, schema) ⇒ Array.<Object>

Validate object against schema. Schema can be passed explicitly or reference a schema from spec.

Kind: instance method of SchemaValidator
Returns: Array.<Object> - An array with errors when object is invalid, undefined otherwise

Param Type Description
entity Object object to validate
schema Object | string object schema

Readme

Keywords

Package Sidebar

Install

npm i @smartrecruiters/openapi-schemas-validator

Weekly Downloads

44

Version

0.3.1

License

MIT

Unpacked Size

18.7 kB

Total Files

12

Last publish

Collaborators

  • bigcreate
  • smartrecruiters-user
  • kiebzak
  • a.khankan.smartrecruiters