Skip to content


Repository files navigation


NPM Version NPM Downloads Node.js Version Licence Build

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


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










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