diff --git a/src/Schema/Keywords/Properties.php b/src/Schema/Keywords/Properties.php index 52ae621a..f250581f 100644 --- a/src/Schema/Keywords/Properties.php +++ b/src/Schema/Keywords/Properties.php @@ -108,7 +108,7 @@ public function validate($data, array $properties, $additionalProperties): void // if not covered by "properties" $schemaValidator->validate( $data[$propName], - $additionalProperties, + $additionalProperties->properties[$propName] ?? $additionalProperties, $this->dataBreadCrumb->addCrumb($propName) ); } diff --git a/tests/Schema/Keywords/PropertiesTest.php b/tests/Schema/Keywords/PropertiesTest.php index 82a146e4..158f4926 100644 --- a/tests/Schema/Keywords/PropertiesTest.php +++ b/tests/Schema/Keywords/PropertiesTest.php @@ -120,4 +120,23 @@ public function testItInfersObjectTypeGreen(): void $this->expectException(KeywordMismatch::class); (new SchemaValidator())->validate($data, $schema); } + + public function testItValidatesAdditionalPropertiesBlue(): void + { + $spec = <<loadRawSchema($spec); + $data = ['flag' => true]; + + (new SchemaValidator())->validate($data, $schema); + $this->addToAssertionCount(1); + } }