Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ $schema = $retriever->retrieve('file://' . realpath('schema.json'));
$data = json_decode(file_get_contents('data.json'));

// If you use $ref or if you are unsure, resolve those references here
// This modifies the $schema object
// This modifies the $schema object, if the schema has a max depth greater than 7
// you can pass as an additional value in the RefResolver
$refResolver = new JsonSchema\RefResolver($retriever);
$refResolver->resolve($schema, 'file://' . __DIR__);

Expand Down
9 changes: 7 additions & 2 deletions src/JsonSchema/RefResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class RefResolver
* maximum references depth
* @var integer
*/
public static $maxDepth = 7;
public static $maxDepth;

/**
* @var UriRetrieverInterface
Expand All @@ -43,10 +43,15 @@ class RefResolver

/**
* @param UriRetriever $retriever
* @param int $maxDepth
*/
public function __construct($retriever = null)
public function __construct($retriever = null, $maxDepth = 7)
{
$this->uriRetriever = $retriever;

if (null === self::$maxDepth) {
self::$maxDepth = $maxDepth;
}
}

/**
Expand Down