https://github.com/ebln/guzzle-openapi-middleware
OpenAPI validation middleware for Guzzle, adapting league/openapi-psr7-validator
https://github.com/ebln/guzzle-openapi-middleware
guzzle guzzle-middleware middleware openapi openapi3 php validation validator
Last synced: 3 months ago
JSON representation
OpenAPI validation middleware for Guzzle, adapting league/openapi-psr7-validator
- Host: GitHub
- URL: https://github.com/ebln/guzzle-openapi-middleware
- Owner: ebln
- License: mit
- Created: 2022-08-19T07:59:26.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-20T13:39:14.000Z (almost 4 years ago)
- Last Synced: 2025-12-14T11:34:08.933Z (7 months ago)
- Topics: guzzle, guzzle-middleware, middleware, openapi, openapi3, php, validation, validator
- Language: PHP
- Homepage:
- Size: 41 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
OpenAPI Validation Middleware for Guzzle
========================================
[This middleware only adapts league/openapi-psr7-validator for Guzzle, please see their project for documentation](https://github.com/thephpleague/openapi-psr7-validator#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]);
```