Skip to content

Schema validators for api documentation in OpenAPI Specification 3.x format.

License

Notifications You must be signed in to change notification settings

smartrecruiters/openapi-schemas-validator

Repository files navigation

@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

About

Schema validators for api documentation in OpenAPI Specification 3.x format.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •