Repository navigation
Add a PSR-15 middleware, and move the adapters off the container - #80
Merged
Merged
Conversation
The Slim adapter registers the new PSR-15 middleware, and the Laravel middleware gets the verifier through its constructor, so `OPENAPI_VERFIER_CONTAINER_KEY` is gone. Since paths are matched against the specification, the verifier no longer has to be registered before Slim's routing middleware.
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.
Third part of the new shape for 3.0, and the last change to the adapters' API. Both middleware used to fetch the test case back out of the container under
OPENAPI_VERFIER_CONTAINER_KEY, just to call its trait methods. They get anOpenApiVerifiernow, and the key is gone.Adapters\Psr15\OpenApiVerifierMiddlewareis new, and works with any PSR-15 stack. A mismatch throwsOpenApiSchemaMismatchException, and an optional callback runs first, to report it in a way of its own.Adapters\Slim\OpenApiVerifierMiddlewareand the probing for a usable container are removed. Since AddOpenApiVerifier, and match paths against the specification's templates #78 matches paths against the specification, the verifier no longer has to be registered before the routing middleware. A new test registers it after routing.handle()andterminate().Also in here, since this is the breaking slice:
$openapiSpecificationgets its real type,object|string|nullwith anulldefault, andfailSchemaMismatch()builds its message withimplode()instead of an eight-placeholdersprintf.Adapters\PSR17Middlewaregoes, andpsr/http-server-middlewareis required, interface-only like the other PSR packages.How a test class uses the adapters does not change:
registerOpenApiVerifier()is called the same way. The phpstan baseline drops from 12 entries to 5. What went were findings from the old design, which typed the verifier it fetched asVerifiesOpenApi, a trait, so none of the calls on it could be checked. Checked locally with highest and lowest dependencies.