• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

DerManoMann / openapi-verifier / 11761253614

10 Nov 2024 01:59AM UTC coverage: 74.545% (+21.6%) from 52.941%
11761253614

push

github

web-flow
Handle routes including placeholders (#62)

12 of 18 new or added lines in 4 files covered. (66.67%)

123 of 165 relevant lines covered (74.55%)

5.28 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Adapters/Slim/OpenApiVerifierMiddleware.php
1
<?php declare(strict_types=1);
2

3
namespace Radebatz\OpenApi\Verifier\Adapters\Slim;
4

5
use Psr\Container\ContainerInterface;
6
use Psr\Http\Server\RequestHandlerInterface;
7
use Radebatz\OpenApi\Verifier\OpenApiSchemaMismatchException;
8
use Radebatz\OpenApi\Verifier\VerifiesOpenApi;
9
use Slim\Routing\RouteContext;
10

11
class OpenApiVerifierMiddleware
12
{
13
    public const OPENAPI_VERFIER_CONTAINER_KEY = 'openapi-verifier';
14

15
    protected $container;
16

17
    public function __construct(ContainerInterface $container)
18
    {
19
        $this->container = $container;
×
20
    }
21

22
    public function __invoke($request, $response, $next = null)
23
    {
24
        $response = $next ? $next($request, $response) : $response;
×
25
        $response = ($response instanceof RequestHandlerInterface) ? $response->handle($request) : $response;
×
26

NEW
27
        $routePath = null;
×
NEW
28
        if ($route = RouteContext::fromRequest($request)->getRoute()) {
×
NEW
29
            $routePath = $route->getPattern();
×
30
        }
31

32
        /** @var VerifiesOpenApi $verifier */
33
        $verifier = $this->container->get(OpenApiVerifierMiddleware::OPENAPI_VERFIER_CONTAINER_KEY);
×
34

35
        try {
NEW
36
            $verifier->verifyOpenApi($request, $response, $routePath);
×
37
        } catch (OpenApiSchemaMismatchException $oasme) {
×
38
            $verifier->failSchemaMismatch($oasme, $response);
×
39

40
            throw $oasme;
×
41
        }
42

43
        return $response;
×
44
    }
45
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc