rebzya/openapi-testing
OpenAPI testing helpers for Laravel and PHP apps: use your OpenAPI spec to drive API contract tests and catch mismatches between documented endpoints and real responses before they ship.
composer require --dev r3bzya/openapi-testing — note the package is pre-1.0, so require an explicit constraint (^0.4) rather than *. v0.4.0 (the 0.3.0 → 0.4.0 bump) shipped with a changelog link only and no written notes, so read the diff on GitHub before upgrading an existing 0.3.x install; minor-number bumps in 0.x packages routinely carry breaking signature changes.php artisan vendor:publish --tag=openapi-testing-config (tag name may differ — check php artisan vendor:publish output). You'll typically be setting the path to your spec (openapi.json / openapi.yaml), the base URL used to resolve relative servers entries, and a strictness/validation mode.$this->getJson(...), acting-as, database factories), then hand the response and the operation (path + method + status code) to the package for schema validation. Keep your existing status-code/JSON-fragment assertions — the spec check is additive, not a replacement.assertMatchesSpec($response, 'GET', '/api/v1/users') in a shared trait keeps tests readable and gives you one place to change when the package's API shifts on the next 0.x bump.$ref resolution is the slow part on large specs.composer update r3bzya/openapi-testing --dry-run, read the diff, then run the suite. Pin to ~0.4.0 if you need stability mid-quarter.$ref resolution is the usual culprit for confusing errors: relative refs break when the spec is loaded from a different working directory (common in CI vs. local), and circular refs can blow up the parser. Absolute-ise the spec path in config rather than relying on cwd.oneOf / anyOf discrimination, nullable (3.0) vs. type: ['string','null'] (3.1), additionalProperties: false with Laravel resources that add meta/links, and integer-vs-string coercion — PHP's JSON decode turns "1" and 1 into different things, and Laravel casts are easy to get wrong. Add an explicit test for any endpoint using these.JsonResource wrapping ({"data": ...}) and pagination meta must exist in the spec or every paginated test fails. Check your JsonResource::withoutWrapping() state before blaming the package.if statements through tests — that wrapper is also your migration shim for 0.5.0.How can I help you explore Laravel packages today?