PHPackages                             sixlive/json-schema-assertions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. sixlive/json-schema-assertions

ActiveLibrary[Testing &amp; Quality](/categories/testing)

sixlive/json-schema-assertions
==============================

JSON Schema assertions

v2.2.0(1y ago)4246.2k↓29.7%52MITPHPPHP ^8.0

Since Sep 20Pushed 1y ago3 watchersCompare

[ Source](https://github.com/sixlive/json-schema-assertions)[ Packagist](https://packagist.org/packages/sixlive/json-schema-assertions)[ Docs](https://github.com/sixlive/json-schema-assertions)[ RSS](/packages/sixlive-json-schema-assertions/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (3)Versions (9)Used By (2)

JSON Schema Assertions
======================

[](#json-schema-assertions)

[![Packagist Version](https://camo.githubusercontent.com/765c12bc477fa07371e5509bdbb515406d0a8933a0676eab05cd60f1cd57327b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369786c6976652f6a736f6e2d736368656d612d617373657274696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sixlive/json-schema-assertions)[![Packagist Downloads](https://camo.githubusercontent.com/2b92573f76227948ac861ed91eb16ba699acb0100c0e460f898bb3fdbdd7cb29/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369786c6976652f6a736f6e2d736368656d612d617373657274696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sixlive/json-schema-assertions)[![StyleCI](https://camo.githubusercontent.com/3db53eb37e097933ac017ca87e5e018f1dbc16a8c93b25cd7fb5b212eaa7452b/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3134373230373936352f736869656c64)](https://github.styleci.io/repos/147207965)

JSON Schema schema assertions for PHP. Uses [swaggest/php-json-schema](https://github.com/swaggest/php-json-schema) under the hood.

Framework Integrations
----------------------

[](#framework-integrations)

- [Laravel](https://github.com/sixlive/laravel-json-schema-assertions)

Installation
------------

[](#installation)

You can install the package via composer:

```
> composer require --dev sixlive/json-schema-assertions
```

Usage
-----

[](#usage)

If you are making use of external schema refrences e.g. `$ref: 'bar.json`, you must reference the schema through file path or using the config path resolution.

```
├── schemas
│   ├── bar.json
│   └── foo.json

```

You can either use the `AssertsJsonSchema` trait or manually construct the schema assertion.

```
use sixlive\JsonSchemaAssertions\Concerns\AssertJsonSchema;

class ExampleTest extends TestCase
{
    use AssertsJsonSchema;

    public function setUp()
    {
        parent::setUp();

        $this->setJsonSchemaBasePath(__DIR__.'/../Schemas');
    }

    /** @test */
    function it_has_a_valid_response()
    {
        $this->schemaAssertion
            ->schema('foo')
            ->assert('{"foo": "bar"}');
    }
}
```

```
/** @test */
public function it_has_a_valid_response()
{
    $schema = [
        'type' => 'object',
        'properties' => [
           'foo' => [
                'type' => 'string',
           ],
         ],
         'required' => [
            'foo',
        ],
    ];

    // Schema as an array
    (new SchemaAssertion)->schema($schema)->assert('{"foo": "bar"}');

    // Schema from raw JSON
    (new SchemaAssertion)->schema(json_encode($schema))->assert('{"foo": "bar"}');

    // Schema from a file
    (new SchemaAssertion)->schema(__DIR__.'/../schemas/foo.json'))
        ->assert('{"foo": "bar"}');

    // Remote schema
    (new SchemaAssertion)->schema('https://docs.foo.io/schemas/foo.json')
        ->assert('{"foo": "bar"}')

    // Schema from a path
    (new SchemaAssertion(__DIR__.'/../schemas/'))
        ->schema('foo')
        ->assert('{"foo": "bar"}');
}
```

Testing
-------

[](#testing)

```
> composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Code Style
----------

[](#code-style)

In addition to the php-cs-fixer rules, StyleCI will apply the [Laravel preset](https://docs.styleci.io/presets#laravel).

### Linting

[](#linting)

```
> composer styles:lint
```

### Fixing

[](#fixing)

```
> composer styles:fix
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [TJ Miller](https://github.com/sixlive)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 86.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~361 days

Recently: every ~441 days

Total

7

Last Release

628d ago

Major Versions

v1.2.0 → v2.0.02021-11-15

PHP version history (4 changes)v1.0.0PHP ^7.1|^7.2

v1.0.1PHP ^7.1|^7.2|^7.3

v1.2.0PHP ^7.1|^8.0

v2.0.0PHP ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5108034?v=4)[TJ Miller](/maintainers/sixlive)[@sixlive](https://github.com/sixlive)

---

Top Contributors

[![sixlive](https://avatars.githubusercontent.com/u/5108034?v=4)](https://github.com/sixlive "sixlive (19 commits)")[![keithbrink](https://avatars.githubusercontent.com/u/15267205?v=4)](https://github.com/keithbrink "keithbrink (1 commits)")[![michaeldyrynda](https://avatars.githubusercontent.com/u/558441?v=4)](https://github.com/michaeldyrynda "michaeldyrynda (1 commits)")[![patrickomeara](https://avatars.githubusercontent.com/u/571773?v=4)](https://github.com/patrickomeara "patrickomeara (1 commits)")

---

Tags

json-schemaphpunitjsonschemasixlivejson\_matchers

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/sixlive-json-schema-assertions/health.svg)

```
[![Health](https://phpackages.com/badges/sixlive-json-schema-assertions/health.svg)](https://phpackages.com/packages/sixlive-json-schema-assertions)
```

###  Alternatives

[sixlive/laravel-json-schema-assertions

Laravel JSON Schema assertions

71209.5k](/packages/sixlive-laravel-json-schema-assertions)[lchrusciel/api-test-case

Perfect PHPUnit TestCase for JSON/XML API TDD with Symfony.

4115.5M63](/packages/lchrusciel-api-test-case)[estahn/phpunit-json-assertions

JSON assertions for PHPUnit (including JSON Schema)

36983.1k7](/packages/estahn-phpunit-json-assertions)[ubirak/rest-api-behat-extension

Rest Api Extension for Behat

41327.0k2](/packages/ubirak-rest-api-behat-extension)[guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。

2227.8k](/packages/guanguans-laravel-soar)[webmozarts/strict-phpunit

Enables type-safe comparisons of objects in PHPUnit

31252.7k5](/packages/webmozarts-strict-phpunit)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
