{"id":15527163,"url":"https://github.com/sixlive/json-schema-assertions","last_synced_at":"2025-04-16T01:23:47.695Z","repository":{"id":46087456,"uuid":"147207965","full_name":"sixlive/json-schema-assertions","owner":"sixlive","description":"JSON Schema assertions for PHP","archived":false,"fork":false,"pushed_at":"2024-08-28T15:30:29.000Z","size":26,"stargazers_count":4,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-06T03:51:14.469Z","etag":null,"topics":["json-schema","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":null,"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}},"created_at":"2018-09-03T13:21:37.000Z","updated_at":"2024-08-28T15:30:04.000Z","dependencies_parsed_at":"2024-11-16T16:04:06.735Z","dependency_job_id":"66ace558-2fbe-45c5-b6d3-a874d3edccd2","html_url":"https://github.com/sixlive/json-schema-assertions","commit_stats":{"total_commits":22,"total_committers":5,"mean_commits":4.4,"dds":"0.31818181818181823","last_synced_commit":"2d9667268e02541c2aa1644fbc57aefc5b4a50d3"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixlive%2Fjson-schema-assertions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixlive%2Fjson-schema-assertions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixlive%2Fjson-schema-assertions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sixlive%2Fjson-schema-assertions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sixlive","download_url":"https://codeload.github.com/sixlive/json-schema-assertions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249179855,"owners_count":21225620,"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","phpunit"],"created_at":"2024-10-02T11:04:48.207Z","updated_at":"2025-04-16T01:23:47.674Z","avatar_url":"https://github.com/sixlive.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON Schema Assertions\n\n[![Packagist Version](https://img.shields.io/packagist/v/sixlive/json-schema-assertions.svg?style=flat-square)](https://packagist.org/packages/sixlive/json-schema-assertions)\n[![Packagist Downloads](https://img.shields.io/packagist/dt/sixlive/json-schema-assertions.svg?style=flat-square)](https://packagist.org/packages/sixlive/json-schema-assertions)\n[![StyleCI](https://github.styleci.io/repos/147207965/shield)](https://github.styleci.io/repos/147207965)\n\nJSON Schema schema assertions for PHP. Uses [swaggest/php-json-schema](https://github.com/swaggest/php-json-schema) under the hood.\n\n## Framework Integrations\n\n* [Laravel](https://github.com/sixlive/laravel-json-schema-assertions)\n\n## Installation\n\nYou can install the package via composer:\n\n```bash\n\u003e composer require --dev sixlive/json-schema-assertions\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├── schemas\n│   ├── bar.json\n│   └── foo.json\n```\n\nYou can either use the `AssertsJsonSchema` trait or manually construct the schema assertion.\n\n```php\nuse sixlive\\JsonSchemaAssertions\\Concerns\\AssertJsonSchema;\n\nclass ExampleTest extends TestCase\n{\n    use AssertsJsonSchema;\n\n    public function setUp()\n    {\n        parent::setUp();\n\n        $this-\u003esetJsonSchemaBasePath(__DIR__.'/../Schemas');\n    }\n\n    /** @test */\n    function it_has_a_valid_response()\n    {\n        $this-\u003eschemaAssertion\n            -\u003eschema('foo')\n            -\u003eassert('{\"foo\": \"bar\"}');\n    }\n}\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    // Schema as an array\n    (new SchemaAssertion)-\u003eschema($schema)-\u003eassert('{\"foo\": \"bar\"}');\n\n    // Schema from raw JSON\n    (new SchemaAssertion)-\u003eschema(json_encode($schema))-\u003eassert('{\"foo\": \"bar\"}');\n\n    // Schema from a file\n    (new SchemaAssertion)-\u003eschema(__DIR__.'/../schemas/foo.json'))\n        -\u003eassert('{\"foo\": \"bar\"}');\n\n    // Remote schema\n    (new SchemaAssertion)-\u003eschema('https://docs.foo.io/schemas/foo.json')\n        -\u003eassert('{\"foo\": \"bar\"}')\n\n    // Schema from a path\n    (new SchemaAssertion(__DIR__.'/../schemas/'))\n        -\u003eschema('foo')\n        -\u003eassert('{\"foo\": \"bar\"}');\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%2Fjson-schema-assertions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsixlive%2Fjson-schema-assertions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsixlive%2Fjson-schema-assertions/lists"}