hotmeteor/spectator
Spectator brings lightweight OpenAPI contract testing to your Laravel test suite. Write tests that guarantee your API spec never drifts from your implementation, with artisan validation commands, operation coverage tracking, and JSON error output for CI.
assertJsonSchema helpers and hand-rolled spec parsing scattered across feature tests. Spectator replaces that with a maintained, MIT-licensed helper layer, so the decision becomes "adopt ~1 dev-day" versus "own a small internal testing utility forever."spectator:validate (spec linting) and spectator:routes (spec↔route cross-reference) produce concrete numbers: operations defined, operations implemented, operations implemented but undocumented. That's a defensible input to a roadmap item like "make the spec authoritative before we publish it to partners."spectator:coverage plus the SpectatorExtension threshold let you decide, deliberately, whether a PR that touches an endpoint without touching its spec fails CI. That is a policy decision with real cost — it slows hotfixes — and this package makes it a one-line config rather than an argument.spectator:routes surfaces endpoints that exist in Laravel but not in the spec — the classic sign of an undocumented internal surface that someone will eventually depend on. Useful for scope-cutting decisions on what to officially support.spectator:stubs generates skeleton tests from the spec, which meaningfully changes the cost estimate for "get every endpoint covered" from weeks to days on a mid-sized API.Adopt when most of these hold:
SPECTATOR_ERROR_FORMAT=json) for CI log parsing or dashboards.Look elsewhere when:
oneOf/discriminator semantics, $ref resolution across multi-file specs. Verify against your spec before committing; the package is deliberately "light-weight."For executives: Our public API is a contract, and today nothing stops the code from quietly diverging from the spec we hand to partners. Spectator is a free, MIT-licensed testing add-on that makes that divergence a failed build instead of a support ticket. It's a dev-only dependency — zero production footprint, no vendor contract, no data leaving our infrastructure — and it runs inside the test suite we already execute. Rough cost is a day or two of setup; the payoff is that SDK generation, partner integration docs, and versioning commitments become trustworthy, which is what lets us promise backwards compatibility without a manual audit each release.
For engineering: Drop it in and you get contract assertions in the PHPUnit tests you already write — no new runtime dependency, no service to run. Three things to know: v3 requires PHP 8.3 / Laravel 12; there are four new artisan commands (spectator:validate, :coverage, :routes, :stubs) that lint the spec, report operation coverage, diff spec against actual routes, and scaffold tests from the spec; and SpectatorExtension can enforce a minimum coverage threshold in CI so the suite can't silently rot. Errors can be emitted as JSON for cleaner CI logs. Risk is low and reversible — dev-only, MIT, small codebase, so if the project stalls we fork or strip it back to our own helpers. Suggested rollout: run spectator:routes on the current codebase first to size the gap, then wire the coverage gate in as advisory before making it blocking.
How can I help you explore Laravel packages today?