/**
* Execute the middleware.
*
* @param ServerRequestInterface $request
* @param ResponseInterface $response
* @param callable $next
*
* @return ResponseInterface
*/
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next)
{
$schema = $this->getSchema($request);
if ($schema instanceof \SplFileObject) {
$validator = JsonValidator::fromFile($schema);
return $validator($request, $response, $next);
}
return $next($request, $response);
}