fr3d / swagger-assertions
Test your API requests and responses against your swagger definition
Installs: 722 536
Dependents: 4
Suggesters: 0
Security: 0
Stars: 138
Watchers: 8
Forks: 26
Open Issues: 6
Requires
- php: >= 7.2
- ext-json: *
- justinrainbow/json-schema: ^5
- phpunit/phpunit: ^8.0||^9.0
- rize/uri-template: ^0.3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- guzzlehttp/guzzle: ^6.3
- psr/http-message: ^1.0
- symfony/http-foundation: >=3.4
Suggests
- symfony/http-foundation: For Symfony constraints
README
Test any API requests and responses match with the models described in the documentation.
This project is compatible with Swagger 2 spec definitions.
Installing via Composer
You can use Composer .
composer require fr3d/swagger-assertions
Usage in PHPUnit
There are two traits for provide predefined helper functions for different assertions.
- AssertsTrait For assert different parts of the response
- Psr7AssertsTrait For assert PSR-7 compatible responses.
- SymfonyAssertsTrait For assert Symfony HTTP Foundation responses.
See examples at examples/PhpUnit
FAQ
- Q: Can this library validate my Swagger definition?
- A: No. This library validate your API requests and responses match your Swagger definition.
License
Code licensed under BSD 2 clauses terms & conditions.
See LICENSE.txt for more information.