diff --git a/src/Api/Validator.php b/src/Api/Validator.php index 17e548b257..818bdbee47 100644 --- a/src/Api/Validator.php +++ b/src/Api/Validator.php @@ -2,6 +2,7 @@ namespace Aws\Api; use Aws; +use stdClass; /** * Validates a schema against a hash of input. @@ -292,6 +293,12 @@ private function checkAssociativeArray($value) private function checkDocumentType($value) { + // To allow objects like value, which + // can be used within a member which type is `Document` + if ($value instanceof stdClass) { + $value = (array) $value; + } + if (is_array($value)) { $typeOfFirstKey = gettype(key($value)); foreach ($value as $key => $val) { diff --git a/tests/Api/ValidatorTest.php b/tests/Api/ValidatorTest.php index 8f1b14229c..701223a7f3 100644 --- a/tests/Api/ValidatorTest.php +++ b/tests/Api/ValidatorTest.php @@ -616,6 +616,25 @@ public function validationProvider() "Found 1 error while validating the input provided for the Foo operation:\n" . "[unionVal] is a union type and must have exactly one non null value" ], + [ + [ + 'type' => 'structure', + 'members' => [ + 'documentMember' => [ + 'type' => 'structure', + 'members' => [], + 'document' => true, + ] + ] + ], + [ + 'documentMember' => [ + 'type' => 'object', + 'properties' => (object) [] + ] + ], + true + ] ]; }