Opis JSON Schema
Installation, licensing and requirements
Opis JSON Schema is a PHP implementation for the JSON Schema standard (draft-07 and draft-06), that will help you validate all sorts of JSON documents, whether they are configuration files or a set of data sent to an RESTful API endpoint.
Features
- Fast validation
- Support for custom filters
- Supports relative and absolute json pointers
- Support for local and global variables
- Advanced schema reuse with mappers
- Support for custom formats
- Support for custom media types
- Support for default value
- And, of course, all the json schema keywords
License
Opis JSON Schema is licensed under Apache License, Version 2.0.
Requirements
- PHP 7.0 or higher
Installation
Opis JSON Schema is available on Packagist and it can be installed from a command line interface by using Composer.
composer require opis/json-schema
Or you could directly reference it into your composer.json
file as a dependency
{
"require": {
"opis/json-schema": "^1.0"
}
}
Documentation
On this site you can find documentation about json schema itself and about the API of this library.
JSON Schema keywords
- Document keywords: $schema, $id
- Metadata keywords: title, description, examples, $comment
- General keywords: type, const, enum, format, default, definitions, $ref
- Conditionals: not, if-then-else, anyOf, oneOf, allOf
- String keywords: minLength, maxLength, pattern, contentEncoding, contentMediaType
- Number/Integer keywords: minimum, exclusiveMinimum, maximum, exclusiveMaximum, multipleOf
- Object keywords: properties, required, dependencies, minProperties, maxProperties, propertyNames, patternProperties, additionalProperties
- Array keywords: minItems, maxItems, uniqueItems, contains, items, additionalItems
- Extra keywords: $vars, $filters (including $func) $map (including $each)