Download the PHP package soyuka/json-schema-bundle without Composer
On this page you can find all versions of the php package soyuka/json-schema-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download soyuka/json-schema-bundle
More information about soyuka/json-schema-bundle
Files in soyuka/json-schema-bundle
Package json-schema-bundle
Short Description Symfony2 tools bundle for Justin Rainbow's json-schema library.
License MIT
Informations about the package json-schema-bundle
Json-schema bundle
Based on a fork of https://github.com/HadesArchitect/JsonSchemaBundle
Features
- Json Schema generation through command (via Doctrine or Php)
- Json Schema validation annotation
- Json Schema service that accepts class instances
Installation
Composer:
Load the bundle:
Json Schema generation
The default is to parse files located in every Entity directory of every Bundle. The default strategy uses php to parse your class (see php-to-json-schema).
If you want to parse another directory, just specify it through the --directory option:
If you want to use Doctrine annotation to generate a json schema, specify the doctrine strategy. Note that the doctrine/orm-bundle will be needed:
Every json schema will be written to the configurable directory of your choice by keeping the following tree architecture:
The default value is %kernel.root_dir%/Resources/validators, so assuming the Entity parsed is in AcmeBundle/Entity/Product, the schema will be written in %kernel.root_dir%/Resources/validators/AcmeBundle/Product.json.
Validation annotation
This bundle adds a JsonSchema class annotation. When no option is given, the validator will look in the json path (same architecture than with schema generation).
The most basic example will be:
If you want to use a json schema at a different location, or even remote, specify the path of your choice:
The schema option value is retrieved using the JsonSchema\Uri\UriRetriever (any value that works there works in the annotation).
Configuration
Translations
Translation domain is JsonSchemaViolations, therefore default translations would be located in:
Every translation will be given following string parameters:
%property%: the property path%expected%: the expected value%invalid%: the current invalid value
Keys are the constraint code, for example with minLength:
Hack
If you want to handle JsonSchema validation yourself, but have issues using Entity instances with justinrainbow/json-schema, you may want to take a look at the PropertyAccessorConstraint. Here, it'll override the ObjectConstraint so that object properties are accessed through the PropertyAccessor. See the Validator class.
Licence
All versions of json-schema-bundle with dependencies
soyuka/php-to-json-schema Version ~1.0.1
symfony/framework-bundle Version ^3.0
symfony/validator Version ^3.0
symfony/property-access Version ^3.0
symfony/finder Version ^3.0
symfony/property-info Version ^3.0
symfony/console Version ^3.0
psr/cache Version ^1.0
