fr3d/swagger-assertions
Laravel testing package adding PHPUnit assertions that validate API responses against your Swagger/OpenAPI definitions. Use it in feature tests to check status codes, schemas, and response structures, keeping documentation and endpoints in sync and catching contract drift early.
Architecture fit: fr3d/swagger-assertions remains a test-time PHP assertion library, not a Laravel runtime package. Its natural fit is contract testing in PHPUnit/Pest/CI: assert that API requests and responses conform to a Swagger definition. It does not belong in production request handling, API gateways, or middleware. For a Laravel team, it is an additive quality gate, not an architecture component. The v1.0.0 release does not change this positioning; it only improves the odds that the quality gate can be stood up on a current toolchain.
Integration feasibility: Feasible but still not turnkey. The library is framework-agnostic and centered on validating HTTP messages/schema artifacts against a Swagger definition, while Laravel feature tests produce Illuminate\Testing\TestResponse and framework-native request objects. Integration still requires an adapter to PSR-7 (or equivalent) or a custom normalizer that extracts method, URI, query, headers, status, and body for assertion. The v1.0.0 removal of the laminas/http dependency reduces the dependency surface and the risk of version conflicts in a Laravel app, but it is a major-version bump: the input/transport expectations of the library may have changed. A small pilot on one endpoint remains the right feasibility test, and that pilot should explicitly confirm what object shape the library now expects.
Technical risk: Moderate, down from moderate-to-high. Positive signals in v1.0.0: the package is being actively maintained again, and it is explicitly tested against latest supported PHP, PHPUnit (and Symfony), which addresses the single largest prior risk — that a 2021-era release would not run on current PHPUnit majors. Dependency reduction on laminas/http is a genuine integration win for a Laravel app. Residual risks: the license is still reported as NOASSERTION, which remains a legal blocker until clarified; dependents appear to remain near zero, so ecosystem validation is still weak; and Swagger/OpenAPI version support is still unaddressed — if the team is on OpenAPI 3.x, this package may still not fit without conversion. The 1.0.0 major bump also implies possible breaking changes to the assertion API or to the expected request/response input, which the changelog does not enumerate.
Key questions: Which spec version is canonical: Swagger 2.0 or OpenAPI 3.x, and did v1.0.0 change support for either? What exactly broke between 0.x and 1.0.0, beyond the laminas/http removal, and what is the new expected input shape (raw PSR-7 messages, PSR-7 interfaces, arrays)? Which PHP, PHPUnit, Pest, and Laravel versions are covered by "latest supported"? Has the license or fork provenance been resolved? Can Laravel test responses be converted to the new expected shape without brittle custom code? Who owns the package internally if it needs patching?
Stack fit: Best fit is a Laravel/PHP monolith or service with an existing PHPUnit-based test suite and a maintained Swagger 2.0 definition. It remains a poor fit as a strategic dependency for an OpenAPI 3-first platform unless a short spike proves compatibility. Install as a dev dependency only, pinned to an exact version (v1.0.0) with a committed lockfile. Because this is a fresh major release, do not float the constraint.
Migration path: Do not migrate the API spec to satisfy the tool. If the team already piloted a 0.x version, treat v1.0.0 as a re-validation rather than a drop-in upgrade: read the diff for the laminas/http removal, re-run the existing adapter against the new version, and confirm assertion behaviour is unchanged before widening coverage. If the team has not started, the upgrade path is the same as before: spike on one high-value endpoint against the canonical spec.
Compatibility: The v1.0.0 notes materially improve confidence on PHP/PHPUnit/Symfony compatibility, but "latest supported" is not a version matrix — verify explicit constraints in composer.json against the team's pinned Laravel/PHP/PHPUnit versions. Re-verify PSR-7 expectations now that laminas/http is gone: the library may depend on PSR-7 interfaces only, on a different concrete implementation, or on raw message strings. Confirm YAML/JSON spec parsing and that auth headers, file uploads, nullable fields, enums, and allOf/oneOf patterns are handled correctly. Keep the Laravel-to-library adapter isolated so it can be replaced or rewritten for the new input shape.
Sequencing: First, complete legal/licence and provenance review — this is unchanged and still gates everything. Second, run a one-to-two-day compatibility spike on v1.0.0 with a single contract test for a critical endpoint. Third, prove it catches both valid and intentionally invalid responses. Fourth, expand to critical paths only, not every endpoint. Fifth, decide whether to keep, fork, or replace after measuring maintenance cost. Run contract assertions alongside existing feature tests rather than replacing them.
Maintenance: Improved but still team-owned. A maintained v1.0.0 with current-toolchain testing and a smaller dependency footprint lowers the expected patch burden and the risk of dependency conflicts in the Laravel app. However, the project is still lightly adopted, so the adopting team owns dependency pinning, upgrade verification at each future release, and an eventual migration path. Treat v1.0.0 as evidence of life, not as a guarantee of sustained maintenance — the release cadence over the next two quarters is the signal to watch.
Support: Community-only; no vendor SLA or commercial backing. Assign an internal owner in platform/QA and document escalation through a fork if upstream goes quiet again. The unresolved licence status must be cleared before broad adoption and is unaffected by this release.
Scaling: Test-time validation scales with CI, not production traffic. Large Swagger files and broad endpoint coverage can slow suites, so split specs by domain and run contract tests in parallel CI jobs. Removing laminas/http may modestly reduce install size and cold-start cost in CI, but the dominant cost remains spec size and endpoint count. Keep assertions focused on critical contracts.
Failure modes: Likely failures include a silent behaviour change or API break introduced by the 0.x → 1.0.0 jump (especially around the removed laminas/http dependency and the expected request/response input), false negatives from Laravel-to-PSR-7 conversion, spec drift, unsupported schema constructs, and ambiguous licensing. Poorly maintained Swagger examples can still create brittle tests. Treat failures as contract-review signals, not automatically as product bugs, until the adapter is proven against v1.0.0.
Ramp-up: Low for PHP developers comfortable with PHPUnit assertions. Moderate for the adapter layer and Swagger 2.0 schema semantics, plus a short additional read of the v1.0.0 changes to confirm input shape. A one-to-two-day spike should still be enough to determine viability; broader rollout should wait for that evidence and a clear owner.
How can I help you explore Laravel packages today?