diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index b8e0bf1194..b8d6d41383 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -3,7 +3,6 @@ global $utopia, $register, $request, $response, $projectDB, $project, $user, $audit, $mail, $mode, $clients; use Utopia\Exception; -use Utopia\Response; use Utopia\Config\Config; use Utopia\Validator\Email; use Utopia\Validator\Text; @@ -19,6 +18,7 @@ use Appwrite\Database\Validator\UID; use Appwrite\Database\Validator\Authorization; use Appwrite\Database\Exception\Duplicate; use Appwrite\Template\Template; +use Appwrite\Utopia\Response; include_once __DIR__ . '/../shared/api.php'; @@ -78,10 +78,8 @@ $utopia->post('/v1/teams') } } - $response - ->setStatusCode(Response::STATUS_CODE_CREATED) - ->json($team->getArrayCopy()) - ; + $response->setStatusCode(Response::STATUS_CODE_CREATED); + $response->dynamic($team, Response::MODEL_TEAM); } ); @@ -130,7 +128,7 @@ $utopia->get('/v1/teams/:teamId') throw new Exception('Team not found', 404); } - $response->json($team->getArrayCopy([])); + $response->dynamic($team, Response::MODEL_TEAM); } ); @@ -159,7 +157,7 @@ $utopia->put('/v1/teams/:teamId') throw new Exception('Failed saving team to DB', 500); } - $response->json($team->getArrayCopy()); + $response->dynamic($team, Response::MODEL_TEAM); } ); diff --git a/app/controllers/web/home.php b/app/controllers/web/home.php index cfec346b91..64c2eb1af8 100644 --- a/app/controllers/web/home.php +++ b/app/controllers/web/home.php @@ -303,27 +303,27 @@ $utopia->get('/open-api-2.json') 'securityDefinitions' => $keys[$platform], 'paths' => [], 'definitions' => [ - // 'Pet' => [ - // 'required' => ['id', 'name'], - // 'properties' => [ - // 'id' => [ - // 'type' => 'integer', - // 'format' => 'int64', - // ], - // 'name' => [ - // 'type' => 'string', - // ], - // 'tag' => [ - // 'type' => 'string', - // ], - // ], - // ], - // 'Pets' => array( - // 'type' => 'array', - // 'items' => array( - // '$ref' => '#/definitions/Pet', - // ), - // ), + 'Pet' => [ + 'required' => ['id', 'name'], + 'properties' => [ + 'id' => [ + 'type' => 'integer', + 'format' => 'int64', + ], + 'name' => [ + 'type' => 'string', + ], + 'tag' => [ + 'type' => 'string', + ], + ], + ], + 'Pets' => array( + 'type' => 'array', + 'items' => array( + '$ref' => '#/definitions/Pet', + ), + ), 'Error' => array( 'required' => array( 0 => 'code', @@ -396,14 +396,14 @@ $utopia->get('/open-api-2.json') 'tags' => [$route->getLabel('sdk.namespace', 'default')], 'description' => ($desc) ? \file_get_contents($desc) : '', - // 'responses' => [ - // 200 => [ - // 'description' => 'An paged array of pets', - // 'schema' => [ - // '$ref' => '#/definitions/Pet', - // ], - // ], - // ], + 'responses' => [ + 200 => [ + 'description' => 'An paged array of pets', + 'schema' => [ + '$ref' => '#/definitions/Pet', + ], + ], + ], ]; if ($extensions) { @@ -546,10 +546,6 @@ $utopia->get('/open-api-2.json') } } - /*foreach ($consoleDB->getMocks() as $mock) { - var_dump($mock['name']); - }*/ - \ksort($output['paths']); $response