2017 © Pedro Pelรกez
 

library laravel-json-schema-assertions

Laravel JSON Schema assertions

image

sixlive/laravel-json-schema-assertions

Laravel JSON Schema assertions

  • Sunday, July 22, 2018
  • by sixlive
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

Laravel JSON Schema Assertions

Packagist Version Packagist Downloads StyleCI, (*1)

JSON Schema schema assertions for Laravel test responses. Uses swaggest/php-json-schema under the hood., (*2)

Installation

You can install the package via composer:, (*3)

> 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., (*4)

Provider registration
, (*5)

// config/app.php

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

, (*6)

Configuration

Publish the packages config file:, (*7)

> 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:, (*8)

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., (*9)

โ”œโ”€โ”€ 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

``` bash, (*10)

composer test, (*11)


## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. ## Contributing Please see [CONTRIBUTING](CONTRIBUTING.md) for details. ## Code Style In addition to the php-cs-fixer rules, StyleCI will apply the [Laravel preset](https://docs.styleci.io/presets#laravel). ### Linting ```bash > composer styles:lint

Fixing

> composer styles:fix

Security

If you discover any security related issues, please email oss@tjmiller.co instead of using the issue tracker., (*12)

Credits

License

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

The Versions

22/07 2018

dev-master

9999999-dev https://github.com/sixlive/laravel-schema-assertions

Laravel JSON Schema assertions

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel schema json sixlive json_matchers

22/07 2018

v0.3.0

0.3.0.0 https://github.com/sixlive/laravel-schema-assertions

Laravel JSON Schema assertions

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel schema json sixlive json_matchers

22/07 2018

dev-add-support-for-config-path-resolution

dev-add-support-for-config-path-resolution https://github.com/sixlive/laravel-schema-assertions

Laravel JSON Schema assertions

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel schema json sixlive json_matchers

18/07 2018

v0.2.0

0.2.0.0 https://github.com/sixlive/laravel-schema-assertions

Laravel JSON Schema assertions

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel schema json sixlive json_matchers

17/07 2018

dev-develop

dev-develop https://github.com/sixlive/laravel-schema-assertions

Laravel JSON Schema assertions

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel schema json sixlive json_matchers

07/07 2018

v0.1.0

0.1.0.0 https://github.com/sixlive/laravel-schema-assertions

Laravel JSON Schema assertions

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel schema json sixlive json_matchers