PHP implementation of JSON schema. Fork of the http://jsonschemaphpv.sourceforge.net/ project

Related tags

API json-schema
Overview

JSON Schema for PHP

Build Status Latest Stable Version Total Downloads

A PHP Implementation for validating JSON Structures against a given Schema with support for Schemas of Draft-3 or Draft-4. Features of newer Drafts might not be supported. See Table of All Versions of Everything to get an overview of all existing Drafts.

See json-schema for more details.

Installation

Library

git clone https://github.com/justinrainbow/json-schema.git

Composer

Install PHP Composer

composer require justinrainbow/json-schema

Usage

For a complete reference see Understanding JSON Schema.

Note: features of Drafts newer than Draft-4 might not be supported!

Basic usage

<?php

$data = json_decode(file_get_contents('data.json'));

// Validate
$validator = new JsonSchema\Validator;
$validator->validate($data, (object)['$ref' => 'file://' . realpath('schema.json')]);

if ($validator->isValid()) {
    echo "The supplied JSON validates against the schema.\n";
} else {
    echo "JSON does not validate. Violations:\n";
    foreach ($validator->getErrors() as $error) {
        printf("[%s] %s\n", $error['property'], $error['message']);
    }
}

Type coercion

If you're validating data passed to your application via HTTP, you can cast strings and booleans to the expected types defined by your schema:

<?php

use JsonSchema\SchemaStorage;
use JsonSchema\Validator;
use JsonSchema\Constraints\Factory;
use JsonSchema\Constraints\Constraint;

$request = (object)[
    'processRefund'=>"true",
    'refundAmount'=>"17"
];

$validator->validate(
    $request, (object) [
    "type"=>"object",
        "properties"=>(object)[
            "processRefund"=>(object)[
                "type"=>"boolean"
            ],
            "refundAmount"=>(object)[
                "type"=>"number"
            ]
        ]
    ],
    Constraint::CHECK_MODE_COERCE_TYPES
); // validates!

is_bool($request->processRefund); // true
is_int($request->refundAmount); // true

A shorthand method is also available:

$validator->coerce($request, $schema);
// equivalent to $validator->validate($data, $schema, Constraint::CHECK_MODE_COERCE_TYPES);

Default values

If your schema contains default values, you can have these automatically applied during validation:

<?php

use JsonSchema\Validator;
use JsonSchema\Constraints\Constraint;

$request = (object)[
    'refundAmount'=>17
];

$validator = new Validator();

$validator->validate(
    $request,
    (object)[
        "type"=>"object",
        "properties"=>(object)[
            "processRefund"=>(object)[
                "type"=>"boolean",
                "default"=>true
            ]
        ]
    ],
    Constraint::CHECK_MODE_APPLY_DEFAULTS
); //validates, and sets defaults for missing properties

is_bool($request->processRefund); // true
$request->processRefund; // true

With inline references

<?php

use JsonSchema\SchemaStorage;
use JsonSchema\Validator;
use JsonSchema\Constraints\Factory;

$jsonSchema = <<<'JSON'
{
    "type": "object",
    "properties": {
        "data": {
            "oneOf": [
                { "$ref": "#/definitions/integerData" },
                { "$ref": "#/definitions/stringData" }
            ]
        }
    },
    "required": ["data"],
    "definitions": {
        "integerData" : {
            "type": "integer",
            "minimum" : 0
        },
        "stringData" : {
            "type": "string"
        }
    }
}
JSON;

// Schema must be decoded before it can be used for validation
$jsonSchemaObject = json_decode($jsonSchema);

// The SchemaStorage can resolve references, loading additional schemas from file as needed, etc.
$schemaStorage = new SchemaStorage();

// This does two things:
// 1) Mutates $jsonSchemaObject to normalize the references (to file://mySchema#/definitions/integerData, etc)
// 2) Tells $schemaStorage that references to file://mySchema... should be resolved by looking in $jsonSchemaObject
$schemaStorage->addSchema('file://mySchema', $jsonSchemaObject);

// Provide $schemaStorage to the Validator so that references can be resolved during validation
$jsonValidator = new Validator( new Factory($schemaStorage));

// JSON must be decoded before it can be validated
$jsonToValidateObject = json_decode('{"data":123}');

// Do validation (use isValid() and getErrors() to check the result)
$jsonValidator->validate($jsonToValidateObject, $jsonSchemaObject);

Configuration Options

A number of flags are available to alter the behavior of the validator. These can be passed as the third argument to Validator::validate(), or can be provided as the third argument to Factory::__construct() if you wish to persist them across multiple validate() calls.

Flag Description
Constraint::CHECK_MODE_NORMAL Validate in 'normal' mode - this is the default
Constraint::CHECK_MODE_TYPE_CAST Enable fuzzy type checking for associative arrays and objects
Constraint::CHECK_MODE_COERCE_TYPES Convert data types to match the schema where possible
Constraint::CHECK_MODE_EARLY_COERCE Apply type coercion as soon as possible
Constraint::CHECK_MODE_APPLY_DEFAULTS Apply default values from the schema if not set
Constraint::CHECK_MODE_ONLY_REQUIRED_DEFAULTS When applying defaults, only set values that are required
Constraint::CHECK_MODE_EXCEPTIONS Throw an exception immediately if validation fails
Constraint::CHECK_MODE_DISABLE_FORMAT Do not validate "format" constraints
Constraint::CHECK_MODE_VALIDATE_SCHEMA Validate the schema as well as the provided document

Please note that using CHECK_MODE_COERCE_TYPES or CHECK_MODE_APPLY_DEFAULTS will modify your original data.

CHECK_MODE_EARLY_COERCE has no effect unless used in combination with CHECK_MODE_COERCE_TYPES. If enabled, the validator will use (and coerce) the first compatible type it encounters, even if the schema defines another type that matches directly and does not require coercion.

Running the tests

composer test                            # run all unit tests
composer testOnly TestClass              # run specific unit test class
composer testOnly TestClass::testMethod  # run specific unit test method
composer style-check                     # check code style for errors
composer style-fix                       # automatically fix code style errors
Comments
  • Two possible improvements to type coercion

    Two possible improvements to type coercion

    It would be useful to have a coercible string representation for null. "null" or '' would work just fine.

    I think also that the coercion should happen only when the subject doesn't match any of the allowed types. Currently, given the following subject

    {
    	"value": "true"
    }
    

    and the following schema

    {
    	"properties": {
    		"value": {
    			"type": ["boolean", "string"]
    		}
    	},
    	"type": "object"
    }
    

    "value" is coerced to boolean, even if its type -- string -- is among the allowed ones.

    What do you think?

    opened by gtuccini 71
  • Add option to apply default values from the schema

    Add option to apply default values from the schema

    For cases when the object being validated does not define a property, but that property has a default value in the schema, set the property value to the default. This PR has been rebased on PR #351.

    Pending Merge 
    opened by erayd 59
  • centralize errors

    centralize errors

    Some improvements to the error system in an effort to make things a little easier for people interested in adding localization, such as https://github.com/justinrainbow/json-schema/issues/363:

    • Added a new class: ConstraintError. This extends an enum class which I've brought into the project to ensure that nobody types constraint types or messages directly into the code (by typehinting addError). I've used it before in a number of projects and have found it quite useful.

    • Converted all error strings into a format that can be passed to sprintf.

    • I had to invent a few new format error types to avoid ambiguity: phoneFormat, ipFormat, styleFormat, timeFormat, urlFormat.

    @bighappyface @erayd @harej

    opened by shmax 55
  • infinite loop with Constraint::CHECK_MODE_APPLY_DEFAULTS

    infinite loop with Constraint::CHECK_MODE_APPLY_DEFAULTS

    I've found an issue, with some schema, the validator will go into an infinite loop and eventually terminate when the allowed memory is exhausted, you can reproduce the issue with this code :

    <?php
    
    include_once __DIR__."/../vendor/autoload.php";
    
    $validator = new \JsonSchema\Validator();
    
    $data = [];
    $schema = (object)['$ref' => 'http://json-schema.org/draft-04/schema'];
    
    echo __LINE__, PHP_EOL;
    
    $validator->validate($data, $schema);
    
    echo __LINE__, PHP_EOL;
    
    $validator->validate($data, $schema, \JsonSchema\Constraints\Constraint::CHECK_MODE_APPLY_DEFAULTS);
    
    echo __LINE__, PHP_EOL;
    

    I'm not sure yet what is causing this. I'll guess a infinite recursion has been introduced in UndefinedConstraint::validateCommonProperties. I'll try to make another reproduction of the bug with a smaller schema

    opened by mathroc 37
  • Add new config option, refactor coerce feature to use this, and simplify the public API

    Add new config option, refactor coerce feature to use this, and simplify the public API

    Why

    • The current API isn't particularly good at exposing new functionality to users...
    • ...and I want to add new functionality (PR #349 and PR #354) and expose it in a sane way.
    • Passing $coerce all over the stack is risky - it's easy to lose track of it when making other changes.
    • The current design mandates exposing internal method arguments ($path and $i) to users.

    Changes

    • Split the Constraint class to make Validator independent from it
    • Add Validator::validate() as the main entry point
    • Turn Validator::coerce() and Validator::check() into aliases
    • Add Factory::setConfig(), getConfig(), addConfig() & removeConfig()
    • Make type-coercion a checkMode option, don't pass $coerce everywhere
    • Add some extra tests
    Needs Review 
    opened by erayd 32
  • Fully implement $ref compliance with draft 4

    Fully implement $ref compliance with draft 4

    This makes public interface breaking changes - should consider bumping the library major version when taking this change

    I tried to make these changes without making too many changes to the existing library, but unfortunately the end result is more changes than I'd really like (including changing some of the unit tests). However, we now have (local) $ref compatibility and it passes all the tests provided for JSON Schema Draft 4 $refs.

    https://github.com/justinrainbow/json-schema/pull/210/files#diff-c1e4a623a503c7f9de75304aae24ae77L21

    The major changes here are:

    • We can do away with the pesky maximum depth, as now we use object references to achieve recursion where necessary within the schema
    • The JSON Pointer resolution has been abstracted in to its own class, with hopefully a clearer and cleaner implementation
    • "definitions" is now resolved, although have not been formally fully tested, it is certainly more functional than it once was

    I've tried to be respectful to the original library, but appreciate my changes may not be to everyone's taste - comments and improvements are obviously very welcome.

    Needs Review 
    opened by araines 30
  • Allow the schema to be an associative array

    Allow the schema to be an associative array

    What

    If the schema supplied to Validator::validate is an array, convert it to an object prior to using it for validation.

    Why

    Because it was requested in #388, and will improve the user-friendliness of the library interface, particularly noting we already support the data to be validated being an associative array.

    opened by erayd 29
  • Fix infinite recursion on some schemas when setting defaults (#359)

    Fix infinite recursion on some schemas when setting defaults (#359)

    Made this PR to collaborate with @mathroc on #359. The root cause has been located and is not a bug, but the recursion needs to be mitigated, as infinite recursion of a validator is in violation of the spec.

    Will backport the fix to 5.2.0 once this PR is merged.

    Changes Relating to #359

    • Add CHECK_MODE_ONLY_REQUIRED_DEFAULTS
    • Don't expand nested defaults (fixes #359)

    Other Changes

    Seeing as I'm doing this defaults-related PR anyway, I figured I might as well do a little tidying-up of the defaults code, plus fix any other bugs I run into while tracking this one down.

    • Fix another bug with trying to fetch an empty URI
    • Refactor defaults to use LooseTypeCheck where appropriate
    • Move default-setting into its own method
    • Rename one of the defaults variables for clarity
    • Add tests:
      • Ensure non-container values aren't treated like containers;
      • Infinite recursion of default objects via $ref
      • Default values do not override defined null
      • Default values of null are correctly applied
    • Fix second test case for DefaultPropertiesTest::testLeaveBasicTypesAlone
    • Fix applying default values of null / not overwriting null (fixes #377)
    opened by erayd 27
  • supported version of PHP in 6.x.x

    supported version of PHP in 6.x.x

    in #390 I proposed to drop support for EOL version of PHP :

    what about dropping support for EOL version of php ? by that I mean documenting that only php 5.6+ version are supported so that we can later use features from 5.6+ without having to release a new major version ? At first the lib would still run fine on 5.3

    this could be done by marking travis test for those version with allow_failures so that support for those versions could still be visible and improved if wanted but wouldn't block new features

    and here is @bighappyface answer:

    @mathroc @erayd while I am open to dropping support for EOL versions of PHP we are obligated to supporting the same versions as composer being we are a dependency:

    https://github.com/composer/composer/blob/eff9326b0de05551e976ca4ddcfc9f057fe29bcb/composer.json#L26

    I would like to keep the discussion going but let's move that elsewhere.

    so, this might be a valid point. but I'm not sure it's a problem for 6.x to drop support for version that are supported by composer. I can get a clear picture of the implications here as I'm not sure when composer update or composer install is run to build composer.phar

    @Seldaek maye you can help us here ?

    opened by mathroc 24
  • [Question] local relative $ref

    [Question] local relative $ref

    I'm using this with Behat to validate a JSON response for APIs. Using 5.2.1.

    If my schema is embedded inside a Behat feature file (say features/my.feature), how do I reference a definition inside schemas/entity.json? Would that definition be able to reference some other definition (schemas/other-entity.json)?

    opened by dkarlovi 23
  • use JsonPointer for path handling

    use JsonPointer for path handling

    crafting a new API, trying to follow the jsonapi-specs, i've realized that error-objects require a json pointer:

    • source: an object containing references to the source of the error, optionally including any of the following members:
      • pointer: a JSON Pointer [RFC6901] to the associated entity in the request document [e.g. /data for a primary data object, or /data/attributes/title for a specific attribute].

    before making more changes, first thing to do was to get all tests working again, especially bringing back all the existing property paths since i don't intend to introduce a large BC which i probably still do? :/

    having had a look at RFC6901 again, i'm curious why JsonPointer#getPropertyPathAsString does include a leading hashmark @jojo1981 - isn't that actually related to the filename rather than the path? checking other existing JsonPointer implementations in PHP, all use path expressions starting with a slash instead.

    as a nice side-effect, using dots in keys wouldn't result in path that is rather hard to understand like tld.company.project[0].content (instead of /tld.company.project/0/content)

    @mirfilip @bighappyface WDYT?

    opened by steffkes 19
  • fix(UndefinedConstraint): add attribute `#[AllowDynamicProperties]`

    fix(UndefinedConstraint): add attribute `#[AllowDynamicProperties]`

    This change will workaround deprecation warning while applying defaults with php8.2

    php8.2 deprecations

    example code

    
    use JsonSchema\Constraints\Constraint;
    use JsonSchema\Validator;
    
    $schema = [
        'type'                 => 'object',
        'required'             => ['prop1'],
        'additionalProperties' => false,
        'properties'           => [
            'prop1' => [
                'type'                 => 'object',
                'required'             => ['prop2'],
                'additionalProperties' => false,
                'properties'           => [
                    'prop2' => [
                        'type'    => 'array',
                        'items'   => [
                            'type' => 'string',
                        ],
                        'default' => ['test'],
                    ],
                ],
            ],
        ],
    ];
    
    $data      = new stdClass();
    $validator = new Validator();
    $validator->validate(
        $data,
        $schema,
        Constraint::CHECK_MODE_APPLY_DEFAULTS
    );
    
    • php 5.3-8.1 - no warning
    • php 8.2 - deprecation warning
    PHP Deprecated:  Creation of dynamic property JsonSchema\Constraints\UndefinedConstraint::$prop2 is deprecated in ...
    

    This change is safe for all php versions >=5.3.0 - online check with 3v4l.org

    opened by rtm-ctrlz 0
  • HTTP to HTTPS redirection breaks remote reference resolution

    HTTP to HTTPS redirection breaks remote reference resolution

    There is an HTTP to HTTPS redirect for every http://asyncapi.com... URL to https://asyncapi.com... which breaks the current implementation.

    Minimal code

    <?php
    
    declare(strict_types = 1);
    
    require __DIR__ . '/vendor/autoload.php';
    
    $data = json_decode(file_get_contents('https://raw.githubusercontent.com/asyncapi/spec/2.0.0/examples/2.0.0/correlation-id.yml'));
    
    // Validate
    $validator = new JsonSchema\Validator;
    $validator->validate($data, (object)['$ref' => 'https://raw.githubusercontent.com/asyncapi/spec-json-schemas/77c40b5aaa5515de537de3ea7eb383f4076c02d5/schemas/2.0.0.json']);
    
    if ($validator->isValid()) {
      echo "The supplied JSON validates against the schema.\n";
    } else {
      echo "JSON does not validate. Violations:\n";
      foreach ($validator->getErrors() as $error) {
        printf("[%s] %s\n", $error['property'], $error['message']);
      }
    }
    
    

    Unexpected result

     PHP Fatal error:  Uncaught JsonSchema\Exception\InvalidSchemaMediaTypeException: Media type application/schema+json expected in /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php:92
    Stack trace:
    #0 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php(209): JsonSchema\Uri\UriRetriever->confirmMediaType()
    #1 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php(181): JsonSchema\Uri\UriRetriever->loadSchema()
    #2 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php(52): JsonSchema\Uri\UriRetriever->retrieve()
    #3 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php(115): JsonSchema\SchemaStorage->addSchema()
    #4 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php(138): JsonSchema\SchemaStorage->getSchema()
    #5 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/SchemaStorage.php(162): JsonSchema\SchemaStorage->resolveRef()
    #6 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/Constraint.php(123): JsonSchema\SchemaStorage->resolveRefSchema()
    #7 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/Constraints/SchemaConstraint.php(92): JsonSchema\Constraints\Constraint->checkUndefined()
    #8 /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/Validator.php(63): JsonSchema\Constraints\SchemaConstraint->check()
    #9 /mnt/files/local_mount/build/foo.php(16): JsonSchema\Validator->validate()
    #10 {main}
      thrown in /mnt/files/local_mount/build/vendor/justinrainbow/json-schema/src/JsonSchema/Uri/UriRetriever.php on line 92
    

    Additional info

    Version

    $ composer show justinrainbow/json-schema | grep version
    versions : * 5.2.12
    
    opened by mxr576 0
  • Another attempt to make it work under PHP 5.3 and PHP 8+

    Another attempt to make it work under PHP 5.3 and PHP 8+

    Build is passing. I left few comments along the way, please ask if anything isn't clear.

    Commit history is a mess. If you're not comfortable squash-merging this PR, I'll be happy to merge everything into one commit.

    opened by sanmai 0
  • WIP! v6.0.0

    WIP! v6.0.0

    • PHP support since version 7.2;
    • Support for php 8.0;
    • Support for php 8.1.

    what do u think about this? isn't it time to abandon the old versions of php? why do we need php 5? for whom?

    opened by fenric 7
  • URI schemas incorrectly validated with FILTER_VALIDATE_URL

    URI schemas incorrectly validated with FILTER_VALIDATE_URL

    Hi,

    The uri, uriref and uri-reference type of fields are incorrectly being validated with filter_var($element, FILTER_VALIDATE_URL); as this php function validates only URLs and it does not (cannot) validate URIs.

    So while the https://example.com is a valid URL the urn:oasis:names:specification:docbook:dtd:xml:4.1.2 is not, however it is a valid URI. Therefore these kind of fields should be validated differently, php does not have built-in functionality to do this. In the related php ticket it is being mentioned that URIs could be validated simply as <scheme>:<extra> or implement RFC 3986.

    Example JSON document that can cause a validation error.

    {
      "openapi": "3.0.2",
      "info": {
        "title": "Example",
        "version": "1.0.0"
      },
      "paths": {
        "/example": {
          "post": {
            "requestBody": {
              "content": {
                "application/xml": {
                  "schema": {
                    "$ref": "#/components/schemas/exampleXml"
                  }
                }
              }
            },
            "responses": {
              "200": {
                "description": "Success"
              }
            }
          }
        }
      },
      "components": {
        "schemas": {
          "exampleXml": {
            "type": "string",
            "xml": {
              "name": "Document",
              "namespace": "urn:isbn:0451450523"
            }
          }
        }
      }
    }
    

    Example script to reproduce the issue.

    <?php declare(strict_types = 1);
    
    require_once('vendor/autoload.php');
    
    use JsonSchema\Validator;
    
    $data = json_decode(file_get_contents('test.json'));
    $schema = json_decode(file_get_contents('https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/schemas/v3.0/schema.json'));
    
    // Validate.
    $validator = new Validator();
    $validator->validate($data, $schema);
    
    if ($validator->isValid()) {
      echo "The supplied JSON validates against the schema.\n";
    }
    else {
      echo "JSON does not validate. Violations:\n";
      foreach ($validator->getErrors() as $error) {
        printf("[%s] %s\n", $error['property'], $error['message']);
      }
    }
    

    The validation error is: [components.schemas.exampleXml.xml.namespace] Invalid URL format.

    (Unrelated but there is also a [components.schemas.exampleXml.$ref] The property $ref is required validation error, however it is not being marked as an issue for example by https://editor.swagger.io/)

    Related:

    • https://www.php.net/manual/en/filter.filters.validate.php
    • https://www.php.net/manual/en/filter.filters.validate.php#110411
    • https://bugs.php.net/bug.php?id=81332
    opened by ycecube 0
  • Fix ObjectIterator for PHP8

    Fix ObjectIterator for PHP8

    Hi, with PHP8.1 the iterator methods of ObjectIterator must be covariant with the PHP core interfaces.

    I didn't know if theres a specific return type for ::current, so I went with the suppress annotation here. Happy to change this to a return type, if there is one?

    Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::current() should either be compatible with Iterator::current(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 42
    
    Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::next() should either be compatible with Iterator::next(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 52
    
    Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::key() should either be compatible with Iterator::key(): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 61
    
    Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::valid() should either be compatible with Iterator::valid(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 71
    
    Deprecated:  Return type of JsonSchema\Iterator\ObjectIterator::rewind() should either be compatible with Iterator::rewind(): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 81
    
    Deprecated: Return type of JsonSchema\Iterator\ObjectIterator::count() should either be compatible with Countable::count(): int, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in [...]/vendor/justinrainbow/json-schema/src/JsonSchema/Iterator/ObjectIterator.php on line 90
    
    opened by R4c00n 2
Releases(5.2.12)
  • 5.2.12(Apr 13, 2022)

  • 5.2.11(Jul 22, 2021)

  • 5.2.10(May 27, 2020)

  • 5.2.9(Sep 25, 2019)

  • 5.2.8(Jan 15, 2019)

  • 5.2.7(Feb 14, 2018)

  • 5.2.6(Oct 21, 2017)

  • 5.2.5(Oct 10, 2017)

  • 5.2.4(Oct 5, 2017)

  • 5.2.3(Oct 5, 2017)

  • 5.2.2(Oct 3, 2017)

    #431 Backports for 5.2.2 (Part 1) #432 Added property name in draft-3 required error #433 Backports for 5.2.2 (Part 2) #450 Backports for 5.2.2 (Part 3)

    Source code(tar.gz)
    Source code(zip)
  • 5.2.1(May 16, 2017)

    #353 Validation of JSON-Schema #405 fix bug when applying defaults #408 SchemaStorage::addSchema() should call BaseConsstraint::arrayToObjectRecursive() on the provide schemas #409 [BUGFIX] Cast empty schema arrays to object #411 [BUGFIX] Split $objectDefinition into $schema and $properties #415 Issue-414: Allow The Option of T or space for Date time. #416 Testcase for minProperties with properties defined + Fix Test #419 [BUGFIX] Split "uri" format into "uri" & "uri-reference", fix meta-schema bug #421 [BUGFIX] Tweak phpdocumentor dependency to avoid install conflicts

    Source code(tar.gz)
    Source code(zip)
  • 5.2.0(Mar 22, 2017)

    #362 (package:// URIs and bundle local copy of the spec schemas) #372 (bugfix for issue #371) #378 (bugfix for #376, add provided schema under a dummy URI) #382 (add quiet / verbose options to CLI script) #383 (add CHECK_MODE_DISABLE_FORMAT) #366 (more unit tests) #389 (allow assoc array as schema) #398 (enable FILTER_FLAG_EMAIL_UNICODE if available) #394 (anyOf / oneOf exceptions - bugfix for #393) #365 (default recursion & bugfixes for #359 & #377, refactor defaults, other minor fixes) #357 (schema validation) #400 (remove stale files from #357)

    Source code(tar.gz)
    Source code(zip)
  • 5.1.0(Feb 22, 2017)

    #349 Add option to apply default values from the schema #354 Option to throw exceptions when an error is encountered #355 Make code-style more consistent

    Source code(tar.gz)
    Source code(zip)
  • 5.0.0(Feb 15, 2017)

  • 4.1.0(Dec 22, 2016)

  • 4.0.1(Nov 9, 2016)

    #322 handle coercion of multiple types #325 handle negative integers #326 update readme for 4.0.0 #328 add php lang tag to code block #330 [BUGFIX] Use unicode matching for patterns

    Source code(tar.gz)
    Source code(zip)
  • 4.0.0(Oct 10, 2016)

    #304 Return points, spelling and dead code #308 Add support for type coercion #310 performance improvements #314 Updated to check that $ref is a string #316 fix(NumberConstraint): force positive value on first arg #317 Add support for $ref on properties #318 chore(phpunit): ignore local phpunit.xml #319 feat(demo): add simple demo script

    Source code(tar.gz)
    Source code(zip)
  • 3.0.1(Aug 26, 2016)

  • 3.0.0(Aug 15, 2016)

    #234 Fix: allow explicit 0 secfracs in datetime format #276 use JsonPointer for path handling #277 New way of handling references #278 Exception interface #282 fix instancing wrong type, breaks inheritance #283 move MinMaxPropertiesTest to proper location #286 Support json_decode assoc #287 Updating to use more correct hostname regex. This fixes #129 #290 Cache the results of RefResolver::resolve() #292 Fix #291 failed tests with lestest PHP #294 Change error reporting for invalid types with multiple valid types

    Source code(tar.gz)
    Source code(zip)
  • 2.0.5(Jun 2, 2016)

    #272 chore(composer): remove version in favor of VCS tags #273 Throw ResourceNotFoundException outside of re-defined error-handler #275 Fix constraint of error

    Source code(tar.gz)
    Source code(zip)
  • 2.0.4(May 24, 2016)

  • 2.0.3(May 10, 2016)

  • 2.0.2(May 9, 2016)

  • 2.0.1(Apr 28, 2016)

  • 2.0.0(Apr 14, 2016)

    #174 Enhancement: Require more recent phpunit/phpunit #223 Fix: Remove conditions never evaluating to true #227 Fix: Generate coverage on one PHP version only #231 fix(composer): reduce minimum php to 5.3.3 #232 Moving constraints min- and maxProperties to ObjectConstraint #238 add rfc3339 helper class #245 #240 Fix RefResolver and make it compatible with draft-04 #246 chore(LICENSE): switch to MIT

    Source code(tar.gz)
    Source code(zip)
  • 1.6.1(Jan 25, 2016)

    #213 Fix exclusive min/max strictness #217 fixup dev-master alias #218 feat(composer): require PHP 5.3.29 (PHP 5.3.x EOL version) minimum #221 feat(Factory): add setConstraintClass #222 feat(travis): pivot to container-based infrastructure

    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Jan 6, 2016)

    #142 Optional extra arguments for custom error messages #143 Add constraint factory #192 Create .gitattributes #194 bugfix: patternProperties raised errors when the pattern has slashes #202 Fix CollectionConstraint to allow uniqueItems to be false #204 Fix path output for required properties #206 An email is a string, not much else. #207 Fix non-6 digit microsecond date time formats #209 RefResolver::$depth restoration after JsonDecodingException

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Sep 8, 2015)

  • 1.4.4(Jul 14, 2015)

    #161 Throw exception if max depth exceeded #168 Enhancement: Speed up builds as much as possible #170 Fix: Start all messages with a capital letter #171 Fix: Be more specific with error message

    Source code(tar.gz)
    Source code(zip)
Owner
Justin Rainbow
Justin Rainbow
Like FormRequests, but for validating against a json-schema

JSON Schema Request Laravels Form Request Validation for JSON Schema documents Installation composer require wt-health/laravel-json-schema-request Us

Webtools Health 1 Feb 3, 2022
Fork of Symfony Rate Limiter Component for Symfony 4

Rate Limiter Component Fork (Compatible with Symfony <=4.4) The Rate Limiter component provides a Token Bucket implementation to rate limit input and

AvaiBook by idealista 4 Apr 19, 2022
Easily integrate custom-made NPS (Net Promoter Score) into your application

Laravel NPS Easily integrate custom-made NPS (Net Promoter Score) to your application. Installation You can install the package via composer: composer

H-FARM Innovation 48 Oct 27, 2022
OpenAPI(v3) Validators for Symfony http-foundation, using `league/openapi-psr7-validator` and `symfony/psr-http-message-bridge`.

openapi-http-foundation-validator OpenAPI(v3) Validators for Symfony http-foundation, using league/openapi-psr7-validator and symfony/psr-http-message

n1215 2 Nov 19, 2021
EXPERIMENTAL plugin extending WPGraphQL to support querying (Gutenberg) Blocks as data, using Server Side Block registries to map Blocks to the GraphQL Schema.

WPGraphQL Block Editor This is an experimental plugin to work toward compatiblity between the WordPress Gutenberg Block Editor and WPGraphQL, based on

WPGraphQL 29 Nov 18, 2022
🍞🧑‍🍳 An on-the-fly GraphQL Schema generator from Eloquent models for Laravel.

An on-the-fly GraphQL Schema generator from Eloquent models for Laravel. Installation Quickstart Model schemas Installation This package requires PHP

Scrn 100 Oct 16, 2022
Code shared by the schema packages

Code shared by the schema packages

PoP CMS Schema 2 Nov 4, 2022
A PHP implementation of the GraphQL specification based on the JavaScript reference implementation

GraphQL This is a PHP implementation of the GraphQL specification based on the JavaScript reference implementation. Related projects DateTime scalar R

Digia 219 Nov 16, 2022
Quickly and easily expose Doctrine entities as REST resource endpoints with the use of simple configuration with annotations, yaml, json or a PHP array.

Drest Dress up doctrine entities and expose them as REST resources This library allows you to quickly annotate your doctrine entities into restful res

Lee Davis 88 Nov 5, 2022
The efficient and elegant JSON:API 1.1 server library for PHP

Woohoo Labs. Yin Woohoo Labs. Yin is a PHP framework which helps you to build beautifully crafted JSON:APIs. Table of Contents Introduction Features W

Woohoo Labs. 237 Nov 28, 2022
The efficient and elegant, PSR-7 compliant JSON:API 1.1 client library for PHP

Woohoo Labs. Yang Woohoo Labs. Yang is a PHP framework which helps you to communicate with JSON:API servers more easily. Table of Contents Introductio

Woohoo Labs. 160 Oct 16, 2022
JSON:API serializer for PHP resources

kwai-jsonapi A JSON:API serializer for PHP classes using PHP attributes. Currently, this library has no support for links. Installation composer requi

Franky Braem 1 Jan 19, 2022
Read and write OpenAPI 3.0.x YAML and JSON files and make the content accessible in PHP objects.

php-openapi Read and write OpenAPI 3.0.x YAML and JSON files and make the content accessible in PHP objects. It also provides a CLI tool for validatin

Carsten Brandt 399 Dec 23, 2022
Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。

Thresh Laravel API 文档生成器,可以将基于 Laravel 项目的项目代码,自动生成 json 或 md 格式的描述文件。 安装 $ composer require telstatic/thresh -vvv 功能 生成 Markdown 文档 生成 Postman 配置文件 生

静止 5 Jul 12, 2021
pedre-response is a standard structure of json response

PedreResponse It's very important to use same structure for responses in large projects that PedreResponse package can do it for you. PedreResponse is

Pedram Rezaei 2 Dec 22, 2021
JSON API (jsonapi.org) package for Laravel applications.

cloudcreativity/laravel-json-api Status This package has now been rewritten, substantially improved and released as the laravel-json-api/laravel packa

Cloud Creativity 753 Dec 28, 2022
Http-kernel - The HttpKernel component provides a structured process for converting a Request into a Response.

HttpKernel Component The HttpKernel component provides a structured process for converting a Request into a Response by making use of the EventDispatc

Symfony 7.8k Jan 9, 2023
Best resources restful api for developers (with JSON:API standar specification design)

List API Best resources restful api for developers (with JSON:API standar specification design). API Resource Endpoint Name Resource Description Al Qu

Noval 2 Jan 18, 2022
It validates PSR-7 messages (HTTP request/response) against OpenAPI specifications

OpenAPI PSR-7 Message (HTTP Request/Response) Validator This package can validate PSR-7 messages against OpenAPI (3.0.x) specifications expressed in Y

The League of Extraordinary Packages 421 Jan 3, 2023