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