{"id":15014478,"url":"https://github.com/sixlive/laravel-json-schema-assertions","last_synced_at":"2025-05-16T19:06:34.374Z","repository":{"id":32672358,"uuid":"139347110","full_name":"sixlive/laravel-json-schema-assertions","owner":"sixlive","description":"JSON Schema assertions for the Laravel framework","archived":false,"fork":false,"pushed_at":"2025-02-21T14:49:37.000Z","size":77,"stargazers_count":70,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T01:37:52.241Z","etag":null,"topics":["json-schema","laravel","php","phpunit"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sixlive.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sixlive"}},"created_at":"2018-07-01T17:11:56.000Z","updated_at":"2025-02-21T14:49:41.000Z","dependencies_parsed_at":"2024-12-17T20:04:22.045Z","dependency_job_id":"534c7a54-947c-41c6-b8a8-d0880bdfaf70","html_url":"https://github.com/sixlive/laravel-json-schema-assertions","commit_stats":{"total_commits":34,"total_committers":6,"mean_commits":5.666666666666667,"dds":"0.17647058823529416","last_synced_commit":"827c46c33a2790f51a56470c19ab58e27c76e3c1"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixlive%2Flaravel-json-schema-assertions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixlive%2Flaravel-json-schema-assertions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixlive%2Flaravel-json-schema-assertions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixlive%2Flaravel-json-schema-assertions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sixlive","download_url":"https://codeload.github.com/sixlive/laravel-json-schema-assertions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254456746,"owners_count":22074238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json-schema","laravel","php","phpunit"],"created_at":"2024-09-24T19:45:40.818Z","updated_at":"2025-05-16T19:06:34.346Z","avatar_url":"https://github.com/sixlive.png","language":"PHP","funding_links":["https://github.com/sponsors/sixlive"],"categories":[],"sub_categories":[],"readme":"# Laravel JSON Schema Assertions\n\n[![Packagist Version](https://img.shields.io/packagist/v/sixlive/laravel-json-schema-assertions.svg?style=flat-square)](https://packagist.org/packages/sixlive/laravel-json-schema-assertions)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/sixlive/laravel-json-schema-assertions.svg?style=flat-square)](https://packagist.org/packages/sixlive/laravel-json-schema-assertions)\n[![StyleCI](https://github.styleci.io/repos/139347110/shield)](https://github.styleci.io/repos/139347110)\n\nJSON Schema schema assertions for Laravel test responses. Uses [swaggest/php-json-schema](https://github.com/swaggest/php-json-schema) under the hood.\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\n\u003e composer require sixlive/laravel-json-schema-assertions\n```\n\nThis 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.\n\n\u003cdetails\u003e\n    \u003csummary\u003eProvider registration\u003c/summary\u003e\n\n```php\n// config/app.php\n\n'providers' =\u003e [\n    sixlive\\Laravel\\JsonSchemaAssertions\\ServiceProvider::class,\n]\n```\n\n\u003c/details\u003e\n\n### Configuration\nPublish the packages config file:\n```bash\n\u003e php artisan vendor:publish --provider=\"sixlive\\Laravel\\JsonSchemaAssertions\\ServiceProvider\" --tag=\"config\"\n```\n\nThis is the contents of the file which will be published at `config/json-schema-assertions`:\n```php\nreturn [\n    'schema_base_path' =\u003e base_path('schemas'),\n];\n```\n\n## Usage\n\nIf 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.\n\n```\n├── app\n├── bootstrap\n├── config\n├── database\n├── public\n├── resources\n├── routes\n├── schemas\n│   ├── bar.json\n│   └── foo.json\n├── storage\n├── tests\n└── vendor\n```\n\n```php\n/** @test */\npublic function it_has_a_valid_response()\n{\n    $schema = [\n        'type' =\u003e 'object',\n        'properties' =\u003e [\n           'foo' =\u003e [\n                'type' =\u003e 'string',\n           ],\n         ],\n         'required' =\u003e [\n            'foo',\n        ],\n    ];\n\n    $response = $this-\u003eget('/foo');\n\n    // Schema as an array\n    $response-\u003eassertJsonSchema($schema);\n\n    // Schema from raw JSON\n    $response-\u003eassertJsonSchema(json_encode($schema));\n\n    // Schema from a file\n    $response-\u003eassertJsonSchema(base_path('schemas/foo.json'));\n\n    // Schema from config path\n    $response-\u003eassertJsonSchema('foo');\n\n    // Remote schema\n    $response-\u003eassertJsonSchema('https://docs.foo.io/schemas/foo.json');\n}\n```\n\n## Testing\n\n``` bash\n\u003e composer test\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Code Style\nIn addition to the php-cs-fixer rules, StyleCI will apply the [Laravel preset](https://docs.styleci.io/presets#laravel).\n\n### Linting\n```bash\n\u003e composer styles:lint\n```\n\n### Fixing\n```bash\n\u003e composer styles:fix\n```\n\n## Security\n\nIf you discover any security related issues, please email oss@tjmiller.co instead of using the issue tracker.\n\n## Credits\n\n- [TJ Miller](https://github.com/sixlive)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixlive%2Flaravel-json-schema-assertions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsixlive%2Flaravel-json-schema-assertions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixlive%2Flaravel-json-schema-assertions/lists"}