From 86fbdeadb9cd0cdf4d2bd6827175005fe750e178 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Wed, 17 Dec 2025 19:53:36 -0800 Subject: [PATCH 1/3] fix: allow object value Allow object value within a member which type is document. --- src/Api/Validator.php | 7 +++++++ tests/Api/ValidatorTest.php | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) 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 + ] ]; } From cd266f9d8b1299b5e42a19a576b4b4adbb132bc1 Mon Sep 17 00:00:00 2001 From: Yenfry Herrera Feliz Date: Mon, 22 Dec 2025 09:04:23 -0800 Subject: [PATCH 2/3] chore: add change entry log --- .changes/nextrelease/fix-object-value-validation.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .changes/nextrelease/fix-object-value-validation.json diff --git a/.changes/nextrelease/fix-object-value-validation.json b/.changes/nextrelease/fix-object-value-validation.json new file mode 100644 index 0000000000..2ddfb83ea3 --- /dev/null +++ b/.changes/nextrelease/fix-object-value-validation.json @@ -0,0 +1,7 @@ +[ + { + "type": "bugfix", + "category": "", + "description": "Add support for objects like value so that it can be validated and accepted when valid." + } +] \ No newline at end of file From 3f2db1d71f5368c3f5c9ccdf13a6d2625c9b11c5 Mon Sep 17 00:00:00 2001 From: Sean O'Brien <60306702+stobrien89@users.noreply.github.com> Date: Mon, 22 Dec 2025 13:15:20 -0500 Subject: [PATCH 3/3] update changelog entry --- .changes/nextrelease/fix-object-value-validation.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changes/nextrelease/fix-object-value-validation.json b/.changes/nextrelease/fix-object-value-validation.json index 2ddfb83ea3..faa9caaf78 100644 --- a/.changes/nextrelease/fix-object-value-validation.json +++ b/.changes/nextrelease/fix-object-value-validation.json @@ -2,6 +2,6 @@ { "type": "bugfix", "category": "", - "description": "Add support for objects like value so that it can be validated and accepted when valid." + "description": "Allow `stdClass` in `Validator` for document types for empty documents to be encoded as JSON objects rather than arrays." } -] \ No newline at end of file +]