ebln / guzzle-openapi-middleware
A Guzzle middleware validating against openapi schema using league/openapi-psr7-validator
v1.0.0
2022-08-20 13:33 UTC
Requires
- php: ^7.4 || ^8.0 || ^8.1
- guzzlehttp/promises: ^1.5
- league/openapi-psr7-validator: ^0.18
- psr/http-message: ^1.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.28
- guzzlehttp/guzzle: ^7.3
- phpmd/phpmd: ^2.12
- phpstan/phpstan: ^1.8
- phpunit/phpunit: ^9.5
- roave/security-advisories: dev-latest
- vimeo/psalm: ^4.26
This package is not auto-updated.
Last update: 2025-03-31 00:27:11 UTC
README
Installation
composer require ebln/guzzle-openapi-middleware
Usage
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use League\OpenAPIValidation\PSR7\ValidatorBuilder;
$builder = new ValidatorBuilder();
// call either setSchemaFactory() or one of the from*() methods optionally add a PSR6 cache
// @see https://github.com/thephpleague/openapi-psr7-validator#readme
$middleware = new Middleware($builder->getRequestValidator(), $builder->getResponseValidator());
// @see https://docs.guzzlephp.org/en/stable/handlers-and-middleware.html#middleware
$stack = HandlerStack::create();
$stack->push($middleware, 'openapi_validation');
$client = new Client(['handler' => $stack]);