public function getRequestBody($method, $path, $contentType) { $schema = $this->getMethod($method, $path); return $this->getBody($schema, $method, $path, $contentType); }
/** * @param RequestInterface $request */ private function assertValidBody(RequestInterface $request) { $body = $request->getBody()->getContents(); $method = $request->getMethod(); $path = $request->getUri()->getPath(); $contentType = $request->getHeaderLine('Content-Type'); $schemaBody = $this->schemaHelper->getRequestBody($method, $path, $contentType); try { $schemaBody->getSchema()->validate($body); } catch (InvalidSchemaException $exception) { $message = sprintf('Request body for %s %s with content type %s does not match schema: %s', strtoupper($method), $path, $contentType, $this->getSchemaErrorsAsString($exception->getErrors())); throw new ValidatorRequestException($message, 0, $exception); } }