- How do I install fr3d/swagger-assertions in a Laravel app?
- Install it as a dev dependency with composer require --dev fr3d/swagger-assertions and pin an exact version with a committed lockfile. It is a test-time assertion library, not a Laravel runtime package, so keep it out of production dependencies. Then wire it into a PHPUnit or Pest test for a single endpoint to confirm it works with your setup.
- Does fr3d/swagger-assertions support OpenAPI 3.x or only Swagger 2.0?
- The package centers on Swagger 2.0 definitions and there is no confirmed support for OpenAPI 3.x. If your canonical spec is OpenAPI 3.x, evaluate actively maintained validators first and treat this package as a fallback only if conversion to Swagger 2.0 is trivial. Confirm version handling in a short spike before adopting.
- Can I use fr3d/swagger-assertions with Laravel TestResponse in PHPUnit or Pest?
- Not out of the box. Laravel feature tests return Illuminate\Testing\TestResponse, while the library expects HTTP message objects, so you will likely need a small adapter or normalizer that extracts method, URI, query, headers, status, and body. Keep that adapter isolated so it can be replaced or removed later.
- Is fr3d/swagger-assertions safe to use in production?
- No. It is a PHPUnit assertion library meant for contract testing in development and CI, not for request handling, middleware, or API gateways. Installing it as a dev dependency keeps it out of your production runtime.
- Which PHP, Laravel, and PHPUnit versions does fr3d/swagger-assertions support?
- The last release was in 2021, which predates current Laravel and PHPUnit majors, so compatibility must be verified. Check the composer.json constraints for PHP and PHPUnit, run a spike against your current stack, and confirm whether it works with Pest if you use it.
- What is the license of fr3d/swagger-assertions?
- The license is reported as NOASSERTION, which is a legal blocker until clarified. Do not adopt the package in a commercial codebase until legal or open-source review resolves the actual license and the repository provenance, since the distributed package name differs from the repository.
- How do I convert a Laravel TestResponse into the request and response shape the package expects?
- Write a small adapter that maps the Laravel test response to the HTTP message format the library expects, capturing method, URI, query string, headers, status code, and body. The library is framework-agnostic, so this translation layer is usually required. Keep the adapter isolated and covered by its own tests so it can be swapped or deleted if you change tools.
- Is fr3d/swagger-assertions still maintained?
- Maintenance from the vendor side is effectively nonexistent: the last release was in 2021 and the package has zero dependents. If you adopt it, expect to own dependency pinning, compatibility patches, and an eventual migration or fork. Assign an internal owner and keep an exit plan.
- What are good alternatives to fr3d/swagger-assertions for Laravel API contract testing?
- Actively maintained OpenAPI validators and schema assertion tools for PHP are generally better long-term bets, especially for OpenAPI 3.x. For a maintained Swagger 2.0 definition inside an existing PHPUnit suite this package can work as an additive quality gate. Compare maintenance status, license clarity, and spec version support before choosing.
- Should I run contract assertions on every Laravel endpoint or just critical paths?
- Start with one high-value endpoint and prove the assertions catch both valid and intentionally invalid responses. Expand to critical paths only rather than every endpoint, and run contract assertions alongside your existing feature tests instead of replacing them. Full coverage rarely justifies the maintenance cost of an old, lightly adopted dependency.