mathrix / openapi-assertions
This package is abandoned and no longer maintained.
The author suggests using the mathrix-education/openapi-assertions package instead.
Validate PSR-7 requests against OpenAPI specification. Heavily based on league/openapi-psr7-validator.
1.0.0
2019-12-13 20:24 UTC
Requires
- php: >=7.1
- league/openapi-psr7-validator: ^0.5.1
- phpunit/phpunit: ^7.0 || ^8.0
Requires (Dev)
- laravel/lumen-framework: 5.7.* || 5.8.* || ^6.0
- mathrix-education/coding-standard: ^1.0.0
- nyholm/psr7: ^1.1
- symfony/psr-http-message-bridge: ^1.2
Suggests
- nyholm/psr7: Required to convert Symfony Response to PSR7 Response (Lumen)
- symfony/psr-http-message-bridge: Required to convert Symfony Response to PSR7 Response (Lumen)
README
Base library of all Mathrix Education SA PHP projects.
Allow to test API responses against an OpenAPI v3 specification. Proudly maintained by Mathieu Bour mathieu@mathrix.fr, Vice-CTO.
The library heavily relies on league/openapi-psr7-validator formerly lezhnev74/openapi-psr7-validator.
Lumen
In order to use OpenAPI assertions with lumen, you need to install symfony/psr-http-message-bridge and nyholm/psr7. You can do it with:
composer require --dev nyholm/psr7 symfony/psr-http-message-bridge
Then, add the LumenOpenAPIAssertions trait to your base TestCase, like so:
use \Mathrix\OpenAPI\Assertions\Lumen\LumenOpenAPIAssertions; class TestCase extends LumenTestCase { use LumenOpenAPIAssertions; public static function setupBeforeClass() { self::$openAPISpecificationPath = PATH_TO_SPEC_YAML; self::bootLumenOpenAPIAssertions(); } }
Usage
To test that an Illuminate Response matches the specification, simply run:
class TestBar extends TesCase { public function testFoo() { // Your test code $this->assertOpenAPIResponse($response); // Where response extends \Illuminate\Http\Response } }