src/Validation/JsonValidator.php
public function validate(Request $request, JsonSchema $annotation)
    {
        if (null === $requestContent = json_decode($request->getContent())) {
            throw new BadJsonRequestException($request->getContent(), null, ['HTTP request body does not contain a JSON payload']);
        }

        if ($annotation->strict && $request->headers->get('Content-Type') !== $annotation->contentType) {
            throw new BadJsonRequestException($request->getContent(), null, ["HTTP request Content-Type must be {$annotation->contentType}"]);
        }

        $this->validator->check(
            $requestContent, (object) ['$ref' => $fullPath = sprintf('file://%s', $this->getSchemaPath($annotation))]
        );

        if (!$this->validator->isValid()) {
            throw new BadJsonRequestException(
                $requestContent,
                $this->validator->getSchemaStorage()->getSchema($fullPath),
                $this->validator->getErrors()
            );
        }
    }
public function validate(Request $request, JsonSchema $annotation)
    {
        if (null === $requestContent = json_decode($request->getContent())) {
            throw new BadJsonRequestException($request->getContent(), null, ['HTTP request body does not contain a JSON payload']);
        }

        if ($annotation->strict && $request->headers->get('Content-Type') !== $annotation->contentType) {
            throw new BadJsonRequestException($request->getContent(), null, ["HTTP request Content-Type must be {$annotation->contentType}"]);
        }

        $this->validator->check(
            $requestContent, (object) ['$ref' => $fullPath = sprintf('file://%s', $this->getSchemaPath($annotation))]
        );

        if (!$this->validator->isValid()) {
            throw new BadJsonRequestException(
                $requestContent,
                $this->validator->getSchemaStorage()->getSchema($fullPath),
                $this->validator->getErrors()
            );
        }
    }
@param Request    $request    An HTTP JSON request to validate
@param JsonSchema $annotation The shit

@throws BadJsonRequestException When the request does not pass
the schema validation