diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index 2ee1d508a6..c5ef65ceda 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -563,7 +563,8 @@ class Response extends SwooleResponse foreach ($data[$key] as $index => $item) { // A model-typed rule handed a raw array would otherwise ship every key it carries. - if (\is_array($item) && (\is_array($rule['type']) || self::hasModel($rule['type']))) { + // Union types are left alone: their branch resolves a model per item. + if (\is_array($item) && !\is_array($rule['type']) && self::hasModel($rule['type'])) { $item = new Document($item); } @@ -602,10 +603,6 @@ class Response extends SwooleResponse } } } else { - if (\is_array($data[$key]) && (\is_array($rule['type']) || self::hasModel($rule['type']))) { - $data[$key] = new Document($data[$key]); - } - if ($data[$key] instanceof Document) { $data[$key] = $this->output($data[$key], $rule['type']); }