Repository navigation
Add a Guzzle middleware and a PSR-18 client that verify responses - #79
Merged
Merged
Conversation
Both check responses on the client side, so verifying needs no framework. `verify()` now rewinds the body after reading it, since a client's caller reads it next.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second part of the new shape for 3.0, and the new feature: verifying on the client side, so no framework is needed. It works against a running server, a mock handler or anything else a client can talk to.
Adapters\Guzzle\OpenApiVerifierMiddlewareverifies when the response promise resolves. A mismatch rejects it, soget()throws, and so doesgetAsync()->wait().Adapters\Psr18\OpenApiVerifyingClientwraps any PSR-18 client, Guzzle's included. Its mismatch exception is not a PSR-18 client exception on purpose, since the request itself was sent.OpenApiVerifier::verify()rewinds the body after reading it. Reading left the stream at its end, which nobody noticed while only framework middleware called the verifier. A client's caller reads the body next, and would have got an empty string.guzzlehttp/guzzlegoes intorequire-devandsuggest.psr/http-clientis required, since it only holds interfaces, likepsr/http-message.ClientAdapterTestruns the same cases through Guzzle sync, Guzzle async and the PSR-18 client, using Guzzle'sMockHandler, and checks that the body can still be read afterwards. Checked locally with highest and lowest dependencies.