You are here

public function RpcResponseFactory::setOutputSchema in JSON-RPC 2.x

Same name and namespace in other branches
  1. 8 src/Shaper/RpcResponseFactory.php \Drupal\jsonrpc\Shaper\RpcResponseFactory::setOutputSchema()

Sets the schema for the response output.

Parameters

array|null $result_schema: The array of the response.

1 call to RpcResponseFactory::setOutputSchema()
RpcResponseFactory::doTransform in src/Shaper/RpcResponseFactory.php

File

src/Shaper/RpcResponseFactory.php, line 71

Class

RpcResponseFactory
Creates RPC Response objects.

Namespace

Drupal\jsonrpc\Shaper

Code

public function setOutputSchema($result_schema) {
  $schema = Json::decode(file_get_contents(__DIR__ . '/response-schema.json'));
  $schema['properties']['result'] = $result_schema;
  $this->outputValidator = new JsonSchemaValidator($schema, $this->validator, Constraint::CHECK_MODE_TYPE_CAST);
}