PHP code example of sixlive / laravel-json-schema-assertions

1. Go to this page and download the library: Download sixlive/laravel-json-schema-assertions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sixlive / laravel-json-schema-assertions example snippets


// config/app.php

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

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

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

    // 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');
}
bash
> php artisan vendor:publish --provider="sixlive\Laravel\JsonSchemaAssertions\ServiceProvider" --tag="config"