From 5e033d509120416dc4267f86acdad49c367611c8 Mon Sep 17 00:00:00 2001 From: Pavel Batanov Date: Tue, 16 Jul 2019 17:29:15 +0300 Subject: [PATCH] Add README note --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 55364e6..a00673d 100644 --- a/README.md +++ b/README.md @@ -51,9 +51,23 @@ $validator = (new \OpenAPIValidation\PSR7\ValidatorBuilder)->fromJsonFile($jsonF $schema = new \cebe\openapi\spec\OpenApi(); // generate schema object by hand $validator = (new \OpenAPIValidation\PSR7\ValidatorBuilder)->fromSchema($schema)->getServerRequestValidator(); -$validator->validate($request); +$match = $validator->validate($request); ``` +As a result you would get and `OperationAddress $match` which has matched the given request. If you already know +the operation which should match your request (i.e you have routing in your project), you can use +`RouterRequestValidator` + +```php +$address = new \OpenAPIValidation\PSR7\OperationAddress('/some/operation', 'post'); + +$validator = (new \OpenAPIValidation\PSR7\ValidatorBuilder)->fromSchema($schema)->getRoutedRequestValidator(); + +$validator->validate($address, $request); +``` + +This would simplify validation a lot and give you more performance. + ### Response Message Validation of `\Psr\Http\Message\ResponseInterface` is a bit more complicated . Because you need not only YAML file and Response itself, but also you need