All Projects → sixlive → Laravel Json Schema Assertions

sixlive / Laravel Json Schema Assertions

Licence: mit
JSON Schema assertions for the Laravel framework

Projects that are alternatives of or similar to Laravel Json Schema Assertions

Laravel Json Schema
Create all your migrations and models from one JSON schema file.
Stars: ✭ 101 (+65.57%)
Mutual labels:  json-schema, laravel
Php Ddd Example
🐘🎯 Hexagonal Architecture + DDD + CQRS in PHP using Symfony 5
Stars: ✭ 1,960 (+3113.11%)
Mutual labels:  laravel, phpunit
Auth Tests
Always-current tests for Laravel's authentication system. Curated by the community.
Stars: ✭ 230 (+277.05%)
Mutual labels:  laravel, phpunit
phpunit-json-assertions
JSON assertions for PHPUnit (including JSON Schema)
Stars: ✭ 30 (-50.82%)
Mutual labels:  json-schema, phpunit
Laravel Vue Boilerplate
🐘 A Laravel 6 SPA boilerplate with a users CRUD using Vue.js 2.6, GraphQL, Bootstrap 4, TypeScript, Sass, and Pug.
Stars: ✭ 472 (+673.77%)
Mutual labels:  laravel, phpunit
Tddd
A Laravel Continuous Integration Package
Stars: ✭ 722 (+1083.61%)
Mutual labels:  laravel, phpunit
Budget
Get a grip on your finances.
Stars: ✭ 609 (+898.36%)
Mutual labels:  laravel, phpunit
Freelancers Market
Laravel Project to help freelance websites clients and freelancers to find each other.
Stars: ✭ 39 (-36.07%)
Mutual labels:  laravel, phpunit
Laravel Cachebuster
Adds MD5 hashes to the URLs of your application's assets, so when they change, their URL changes.
Stars: ✭ 58 (-4.92%)
Mutual labels:  laravel
Laravel Simple Uploader
Simple file uploader for Laravel 5.
Stars: ✭ 59 (-3.28%)
Mutual labels:  laravel
Cronmon
PHP Web app to monitor cron/scheduled tasks
Stars: ✭ 55 (-9.84%)
Mutual labels:  laravel
Laravel Health Check
A package for checking the health of your Laravel & Lumen applications
Stars: ✭ 59 (-3.28%)
Mutual labels:  laravel
Laravel Multiauth
Simple Multiple auth system using guards
Stars: ✭ 59 (-3.28%)
Mutual labels:  laravel
Laravel Paytm Wallet
Integrate paytm wallet in your laravel application easily with this package. This package uses official Paytm PHP SDK's.
Stars: ✭ 58 (-4.92%)
Mutual labels:  laravel
Lashop
Simple shop based on Laravel 7.3
Stars: ✭ 60 (-1.64%)
Mutual labels:  laravel
It
A Simple Track To Make Sense
Stars: ✭ 55 (-9.84%)
Mutual labels:  laravel
Laravel Reactions
Laravel reactions package for implementing reactions (eg: like, dislike, love, emotion, etc) on Eloquent models.
Stars: ✭ 58 (-4.92%)
Mutual labels:  laravel
Lara shop v2
Single store shopping system developed with laravel5_7.
Stars: ✭ 61 (+0%)
Mutual labels:  laravel
Laravelinventry
Stock management application using Laravel 5.4
Stars: ✭ 60 (-1.64%)
Mutual labels:  laravel
Vultrdash
Vultr self-hosted dashboard.
Stars: ✭ 59 (-3.28%)
Mutual labels:  laravel

Laravel JSON Schema Assertions

Packagist Version Packagist Downloads StyleCI

JSON Schema schema assertions for Laravel test responses. Uses swaggest/php-json-schema under the hood.

Installation

You can install the package via composer:

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

This package uses Laravel's 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

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

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

> composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Code Style

In addition to the php-cs-fixer rules, StyleCI will apply the Laravel preset.

Linting

> composer styles:lint

Fixing

> composer styles:fix

Security

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

Credits

License

The MIT License (MIT). Please see License File for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].