PHPackages                             sixlive/laravel-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/laravel-json-schema-assertions

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

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

Laravel JSON Schema assertions

v4.4.0(1y ago)72211.8k↓38.3%13MITPHPPHP ^8.0CI failing

Since Jul 7Pushed 1y ago2 watchersCompare

[ Source](https://github.com/sixlive/laravel-json-schema-assertions)[ Packagist](https://packagist.org/packages/sixlive/laravel-json-schema-assertions)[ Docs](https://github.com/sixlive/laravel-schema-assertions)[ GitHub Sponsors](https://github.com/sixlive)[ RSS](/packages/sixlive-laravel-json-schema-assertions/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (5)Versions (19)Used By (0)

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

[](#laravel-json-schema-assertions)

[![Packagist Version](https://camo.githubusercontent.com/3168780b38acfc660c37390c4bd78b6e713364a4ffeead97a527fbe57aa7c4f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369786c6976652f6c61726176656c2d6a736f6e2d736368656d612d617373657274696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sixlive/laravel-json-schema-assertions)[![Packagist Downloads](https://camo.githubusercontent.com/e8d3d4d3198643425fe860fd8afa63db7f84d17a523eb94242c5d3818f1cc333/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369786c6976652f6c61726176656c2d6a736f6e2d736368656d612d617373657274696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sixlive/laravel-json-schema-assertions)[![StyleCI](https://camo.githubusercontent.com/7e708217b53abdbbca3d0434512020da463dde6c217a6783505b8e55e9eacd86/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3133393334373131302f736869656c64)](https://github.styleci.io/repos/139347110)

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

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

[](#installation)

You can install the package via composer:

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

This package uses Laravel's [package discovery](https://laravel.com/docs/5.6/packages#package-discovery) to register the service provider to the framework. If you are using an older version of Laravel or do not use package discovery see below.

 Provider registration```
// config/app.php

'providers' => [
    sixlive\Laravel\JsonSchemaAssertions\ServiceProvider::class,
]
```

### Configuration

[](#configuration)

Publish the packages config file:

```
> php artisan vendor:publish --provider="sixlive\Laravel\JsonSchemaAssertions\ServiceProvider" --tag="config"
```

This is the contents of the file which will be published at `config/json-schema-assertions`:

```
return [
    'schema_base_path' => base_path('schemas'),
];
```

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.

```
├── app
├── bootstrap
├── config
├── database
├── public
├── resources
├── routes
├── schemas
│   ├── bar.json
│   └── foo.json
├── storage
├── tests
└── vendor

```

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

    $response = $this->get('/foo');

    // Schema as an array
    $response->assertJsonSchema($schema);

    // Schema from raw JSON
    $response->assertJsonSchema(json_encode($schema));

    // Schema from a file
    $response->assertJsonSchema(base_path('schemas/foo.json'));

    // Schema from config path
    $response->assertJsonSchema('foo');

    // Remote schema
    $response->assertJsonSchema('https://docs.foo.io/schemas/foo.json');
}
```

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

51

—

FairBetter than 95% of packages

Maintenance44

Moderate activity, may be stable

Popularity46

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~151 days

Recently: every ~112 days

Total

17

Last Release

497d ago

Major Versions

v0.4.0 → v1.0.02019-02-24

V1.2.0 → v2.0.02019-10-30

v2.0.0 → v3.0.02020-04-28

v3.1.0 → v4.0.02021-11-15

PHP version history (5 changes)v0.1.0PHP ^7.1|^7.2

v1.0.0PHP &gt;=7.1

v2.0.0PHP &gt;=7.2

v3.1.0PHP &gt;=7.2|^8.0

v4.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 (28 commits)")[![laravel-shift](https://avatars.githubusercontent.com/u/15991828?v=4)](https://github.com/laravel-shift "laravel-shift (3 commits)")[![chrudosvorlicek](https://avatars.githubusercontent.com/u/4454957?v=4)](https://github.com/chrudosvorlicek "chrudosvorlicek (1 commits)")[![jloosli](https://avatars.githubusercontent.com/u/617816?v=4)](https://github.com/jloosli "jloosli (1 commits)")[![matthewtrask](https://avatars.githubusercontent.com/u/4731244?v=4)](https://github.com/matthewtrask "matthewtrask (1 commits)")[![patrickomeara](https://avatars.githubusercontent.com/u/571773?v=4)](https://github.com/patrickomeara "patrickomeara (1 commits)")

---

Tags

json-schemalaravelphpphpunitjsonlaravelschemasixlivejson\_matchers

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k42.5M40.9k](/packages/orchestra-testbench)[hotmeteor/spectator

Testing helpers for your OpenAPI spec

3051.6M1](/packages/hotmeteor-spectator)[guanguans/laravel-soar

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

2248.4k](/packages/guanguans-laravel-soar)[api-platform/laravel

API Platform support for Laravel

58171.5k14](/packages/api-platform-laravel)[ecotone/laravel

Ecotone for Laravel — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Laravel Queue, via PHP attributes.

21318.6k3](/packages/ecotone-laravel)

PHPackages © 2026

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