Skip to content

Commit

Permalink
Also dereference array definitions prior to default value check
Browse files Browse the repository at this point in the history
  • Loading branch information
erayd committed Feb 13, 2018
1 parent 91f5891 commit 8a5ac14
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/JsonSchema/Constraints/UndefinedConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ protected function applyDefaultValues(&$value, $schema, $path)
}
// $value is an array, and items are defined - treat as plain array
foreach ($items as $currentItem => $itemDefinition) {
$itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
if (
!array_key_exists($currentItem, $value)
&& property_exists($itemDefinition, 'default')
Expand Down
2 changes: 1 addition & 1 deletion tests/Constraints/DefaultPropertiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function getValidTests()
),
array(// #16 infinite recursion via $ref (array)
'[]',
'{"items":[{"$ref":"#","default":[]}]}',
'{"items":[{"$ref":"#","default":"valueOne"}], "default": []}',
'[[]]'
),
array(// #17 default top value does not overwrite defined null
Expand Down

0 comments on commit 8a5ac14

Please sign in to comment.