Example #1
0
 public function __construct($schema = null, $request = null, $status = 200, $headers = [], $options = 0)
 {
     if (!$request instanceof Request) {
         throw new \InvalidArgumentException(sprintf('Request is not an instance of %s', Request::class));
     }
     if ($schema === null) {
         $schema = new JsonSchema();
     } elseif (!$schema instanceof JsonSchema) {
         throw new \InvalidArgumentException(sprintf('Document is not an instance of %s', JsonSchema::class));
     }
     $options |= JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT;
     $schema->setSchema('http://json-schema.org/draft-04/schema#');
     $schema->sort(['id', '$schema', 'title', 'description', 'type', 'properties', 'patternProperties', 'required', 'additionalProperties', '{data}', '@meta', '@controls', '@error', '@namespaces']);
     $headers['Content-Type'] = self::MIME_TYPE;
     $headers = array_merge($headers, self::$defaultHeaders);
     parent::__construct($schema, $status, $headers, $options);
     $this->applyEtag($request);
 }
 public function __construct($request = null, $properties = [])
 {
     parent::__construct($request, $properties);
     $this->setProperty('offset', 'integer', ['title' => 'Number of records to skip in the result set', 'default' => 0])->setProperty('limit', 'integer', ['title' => 'Maximum number of items to return', 'default' => MasonCollection::DEFAULT_PER_PAGE, 'maximum' => MasonCollection::MAX_PER_PAGE]);
 }