diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php index e49ace4486..52ddc1d53e 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Frameworks/XList.php @@ -79,9 +79,17 @@ class XList extends Base } } + // Response models only filter nested Documents; plain arrays ship every key they carry. + $frameworks = \array_map(fn (array $framework) => new Document(\array_replace($framework, [ + 'adapters' => \array_map( + fn (array $adapter) => new Document($adapter), + $framework['adapters'] ?? [] + ), + ])), \array_values($frameworks)); + $response->dynamic(new Document([ 'total' => count($frameworks), - 'frameworks' => \array_values($frameworks) + 'frameworks' => $frameworks ]), Response::MODEL_FRAMEWORK_LIST); } } diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index c5ef65ceda..aa261a320b 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -562,12 +562,6 @@ 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. - // 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); - } - if ($item instanceof Document) { $ruleType = null; diff --git a/tests/unit/Utopia/ResponseTest.php b/tests/unit/Utopia/ResponseTest.php index 2d83240b44..e00809ce26 100644 --- a/tests/unit/Utopia/ResponseTest.php +++ b/tests/unit/Utopia/ResponseTest.php @@ -188,27 +188,6 @@ final class ResponseTest extends TestCase $this->assertArrayNotHasKey('hidden', $single); } - public function testResponseModelListsOfArrays(): void - { - $output = $this->response->output(new Document([ - 'singles' => [ - [ - 'string' => 'lorem ipsum', - 'integer' => 123, - 'boolean' => true, - 'hidden' => 'secret' - ] - ], - ]), 'lists'); - - $this->assertCount(1, $output['singles']); - - $single = $output['singles'][0]; - $this->assertArrayHasKey('string', $single); - $this->assertArrayHasKey('required', $single); - $this->assertArrayNotHasKey('hidden', $single); - } - public function testResponseModelNested(): void { $output = $this->response->output(new Document([