PHPackages                             vgirol/jsonapi-assert - 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. [API Development](/categories/api)
4. /
5. vgirol/jsonapi-assert

AbandonedArchivedLibrary[API Development](/categories/api)

vgirol/jsonapi-assert
=====================

This package provides a set of assertions to test documents using the JSON:API specification.

v2.2.2(5y ago)07083MITPHPPHP ^7.3|^8.0

Since Mar 31Pushed 5y ago1 watchersCompare

[ Source](https://github.com/VGirol/JsonApi-Assert)[ Packagist](https://packagist.org/packages/vgirol/jsonapi-assert)[ Docs](http://github.com/VGirol/JsonApi-Assert)[ RSS](/packages/vgirol-jsonapi-assert/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (3)

JsonApi-Assert
==============

[](#jsonapi-assert)

[![Latest Version on Packagist](https://camo.githubusercontent.com/46cfa6d6fb2ca8840af3260d70f4a910c5c81292d7c119f8e8dc179e269d7892/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f564769726f6c2f4a736f6e4170692d4173736572742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/VGirol/JsonApi-Assert)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/ecbe08f08e1707e28d6253310af27f0f0645db4f5698a37ba12f13169916a1ac/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f564769726f6c2f4a736f6e4170692d4173736572742f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/VGirol/JsonApi-Assert)[![Coverage Status](https://camo.githubusercontent.com/fdce950e457288d7b4204e19d76276e29181cbe92083a99d9b22fdecb1eb381b/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f564769726f6c2f4a736f6e4170692d4173736572742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/VGirol/JsonApi-Assert/code-structure)[![Quality Score](https://camo.githubusercontent.com/fa3f7b2924377f971e70482743109d7db2224d54767aaec5fedfe45ea9c2e4de/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f564769726f6c2f4a736f6e4170692d4173736572742e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/VGirol/JsonApi-Assert)[![Infection MSI](https://camo.githubusercontent.com/7d65013afb47548b04d73152d942131ac551a5923b474ce61a67db792135a7da/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742d7371756172652675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246564769726f6c2532464a736f6e4170692d4173736572742532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/VGirol/JsonApi-Assert/master)[![Total Downloads](https://camo.githubusercontent.com/36ce2b36492e46283acf0a2279108891eb0c3b542e0d9a3ed309a07110ba3a07/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f564769726f6c2f4a736f6e4170692d4173736572742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/VGirol/JsonApi-Assert)

This package provides a set of assertions to test documents using the [JSON:API specification](https://jsonapi.org/).

Technologies
------------

[](#technologies)

- PHP 7.3+
- PHPUnit 9.0+

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

[](#installation)

To install through composer, simply put the following in your `composer.json` file:

```
{
    "require-dev": {
        "vgirol/jsonapi-assert": "dev-master"
    }
}
```

And then run `composer install` from the terminal.

### Quick Installation

[](#quick-installation)

Above installation can also be simplified by using the following command:

```
composer require vgirol/jsonapi-assert
```

Usage
-----

[](#usage)

You can use these assertions in your classes directly as a static call.

```
use VGirol\JsonApiAssert\Assert as JsonApiAssert;

class MyTest extends TestCase
{
    /**
     * @test
     */
    public function my_first_test()
    {
        $json = [
            'meta' => [
                'key' => 'value'
            ],
            'jsonapi' => [
                'version' => '1.0'
            ]
        ];

        JsonApiAssert::assertHasValidStructure($json);
    }
}
```

```
use VGirol\JsonApiAssert\Assert as JsonApiAssert;
use VGirol\JsonApiAssert\SetExceptionsTrait;
use VGirol\JsonApiStructure\Messages;

class MyTest extends TestCase
{
    use SetExceptionsTrait;

    /**
     * @test
     */
    public function how_to_assert_that_a_test_failed()
    {
        $json = [
            'errors' => [
                'error' => 'not an array of error objects'
            ]
        ];
        $failureMessage = Messages::ERRORS_OBJECT_MUST_BE_ARRAY;

        $this->setAssertionFailure($failureMessage);

        JsonApiAssert::assertHasValidStructure($json);
    }
}
```

Documentation
-------------

[](#documentation)

The API documentation is available in XHTML format at the url .

Changelog
---------

[](#changelog)

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

Testing
-------

[](#testing)

```
composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CODE\_OF\_CONDUCT](CODE_OF_CONDUCT.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Vincent Girol](mailto:vincent@girol.fr)
- [All Contributors](../../contributors)

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~56 days

Recently: every ~89 days

Total

14

Last Release

1866d ago

Major Versions

v1.2.1 → v2.0.02020-01-26

1.2.x-dev → v2.2.02020-11-19

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

v2.0.0PHP ~7.2.9|^7.3

v2.2.0PHP ^7.3

v2.2.2PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/c5077b4f7fc77f8df031535dc5c832fa9ce6b6d2c90132e3093ea6648bfcde46?d=identicon)[VGirol](/maintainers/VGirol)

---

Top Contributors

[![VGirol](https://avatars.githubusercontent.com/u/18059718?v=4)](https://github.com/VGirol "VGirol (224 commits)")

---

Tags

assertionsJSON-APIunit-testsvgiroljsonapi-assert

### Embed Badge

![Health badge](/badges/vgirol-jsonapi-assert/health.svg)

```
[![Health](https://phpackages.com/badges/vgirol-jsonapi-assert/health.svg)](https://phpackages.com/packages/vgirol-jsonapi-assert)
```

###  Alternatives

[neomerx/json-api

Framework agnostic JSON API (jsonapi.org) implementation

7373.6M27](/packages/neomerx-json-api)[cloudcreativity/laravel-json-api

JSON API (jsonapi.org) support for Laravel applications.

7881.1M5](/packages/cloudcreativity-laravel-json-api)[laravel-json-api/laravel

JSON:API for Laravel applications.

6371.4M15](/packages/laravel-json-api-laravel)[timacdonald/json-api

A Lightweight JSON:API Resource for Laravel

639892.5k2](/packages/timacdonald-json-api)[art4/json-api-client

JSON API client

139791.3k7](/packages/art4-json-api-client)[cloudcreativity/json-api-testing

PHPUnit test helpers to check JSON API documents.

141.6M3](/packages/cloudcreativity-json-api-testing)

PHPackages © 2026

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