Skip to content

Commit 8a5ac14

Browse files
committed
Also dereference array definitions prior to default value check
1 parent 91f5891 commit 8a5ac14

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

src/JsonSchema/Constraints/UndefinedConstraint.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ protected function applyDefaultValues(&$value, $schema, $path)
265265
}
266266
// $value is an array, and items are defined - treat as plain array
267267
foreach ($items as $currentItem => $itemDefinition) {
268+
$itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition);
268269
if (
269270
!array_key_exists($currentItem, $value)
270271
&& property_exists($itemDefinition, 'default')

tests/Constraints/DefaultPropertiesTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function getValidTests()
126126
),
127127
array(// #16 infinite recursion via $ref (array)
128128
'[]',
129-
'{"items":[{"$ref":"#","default":[]}]}',
129+
'{"items":[{"$ref":"#","default":"valueOne"}], "default": []}',
130130
'[[]]'
131131
),
132132
array(// #17 default top value does not overwrite defined null

0 commit comments

Comments
 (0)