@@ -13,7 +13,7 @@ class RefResolver
13
13
public $ url ;
14
14
/** @var null|RefResolver */
15
15
private $ rootResolver ;
16
- private static int $ MAX_DEEP_NESTING = 500 ; //Change this if you receive DEEP_NESTING exceptions
16
+ private int $ max_deep_nesting = 200 ; //Change this via options submitted to ::import if needed
17
17
18
18
/**
19
19
* @param mixed $resolutionScope
@@ -103,9 +103,10 @@ public function setupResolutionScope($id, $data)
103
103
* RefResolver constructor.
104
104
* @param JsonSchema $rootData
105
105
*/
106
- public function __construct ($ rootData = null )
106
+ public function __construct ($ rootData = null , int $ max_nest_level = 200 )
107
107
{
108
108
$ this ->rootData = $ rootData ;
109
+ $ this ->max_deep_nesting = $ max_nest_level ;
109
110
}
110
111
111
112
public function setRootData ($ rootData )
@@ -225,8 +226,8 @@ public function resolveReference($referencePath)
225
226
*/
226
227
public function preProcessReferences ($ data , Context $ options , $ nestingLevel = 0 )
227
228
{
228
- if ($ nestingLevel > self :: $ MAX_DEEP_NESTING ) { //Updated due to specific recursion depth from Amazon product JSON Schemas - yep 200 was not enough
229
- throw new Exception ('Too deep nesting level ' , Exception::DEEP_NESTING );
229
+ if ($ nestingLevel > $ this -> max_deep_nesting ) { //Updated due to specific recursion depth from Amazon product JSON Schemas - yep 200 was not enough
230
+ throw new Exception ('Too deep nesting level. Suggest submitting maxNestLevel via options ' , Exception::DEEP_NESTING );
230
231
}
231
232
if (is_array ($ data )) {
232
233
foreach ($ data as $ key => $ item ) {
0 commit comments