diff --git a/src/Appwrite/GraphQL/Schema.php b/src/Appwrite/GraphQL/Schema.php index 0b9c7d4162..11f728e571 100644 --- a/src/Appwrite/GraphQL/Schema.php +++ b/src/Appwrite/GraphQL/Schema.php @@ -99,33 +99,26 @@ class Schema /** @var Route $route */ $namespace = $route->getLabel('sdk.namespace', ''); - $methods = $route->getLabel('sdk.method', ''); + $method = $route->getLabel('sdk.method', ''); + $name = $namespace . \ucfirst($method); - if (!\is_array($methods)) { - $methods = [$methods]; + if (empty($name)) { + continue; } - foreach ($methods as $method) { - $name = $namespace . \ucfirst($method); - - if (empty($name)) { - continue; - } - - foreach (Mapper::route($utopia, $route, $complexity) as $field) { - switch ($route->getMethod()) { - case 'GET': - $queries[$name] = $field; - break; - case 'POST': - case 'PUT': - case 'PATCH': - case 'DELETE': - $mutations[$name] = $field; - break; - default: - throw new \Exception("Unsupported method: {$route->getMethod()}"); - } + foreach (Mapper::route($utopia, $route, $complexity) as $field) { + switch ($route->getMethod()) { + case 'GET': + $queries[$name] = $field; + break; + case 'POST': + case 'PUT': + case 'PATCH': + case 'DELETE': + $mutations[$name] = $field; + break; + default: + throw new \Exception("Unsupported method: {$route->getMethod()}"); } } } diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index 6409690fc0..185e36f34e 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -123,7 +123,7 @@ class OpenAPI3 extends Format $consumes = [$route->getLabel('sdk.request.type', 'application/json')]; - $id = $route->getLabel('sdk.method', \uniqid()); + $method = $route->getLabel('sdk.method', \uniqid()); $desc = (!empty($route->getLabel('sdk.description', ''))) ? \realpath(__DIR__ . '/../../../../' . $route->getLabel('sdk.description', '')) : null; $produces = $route->getLabel('sdk.response.type', null); $model = $route->getLabel('sdk.response.model', 'none'); @@ -154,17 +154,17 @@ class OpenAPI3 extends Format $temp = [ 'summary' => $route->getDesc(), - 'operationId' => $route->getLabel('sdk.namespace', 'default') . ucfirst($id), + 'operationId' => $route->getLabel('sdk.namespace', 'default') . ucfirst($method), 'tags' => [$route->getLabel('sdk.namespace', 'default')], 'description' => ($desc) ? \file_get_contents($desc) : '', 'responses' => [], 'x-appwrite' => [ // Appwrite related metadata - 'method' => $route->getLabel('sdk.method', \uniqid()), + 'method' => $method, 'weight' => $route->getOrder(), 'cookies' => $route->getLabel('sdk.cookies', false), 'type' => $route->getLabel('sdk.methodType', ''), 'deprecated' => $route->getLabel('sdk.deprecated', false), - 'demo' => Template::fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')) . '/' . Template::fromCamelCaseToDash($id) . '.md', + 'demo' => Template::fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')) . '/' . Template::fromCamelCaseToDash($method) . '.md', 'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $route->getLabel('sdk.description', ''), 'rate-limit' => $route->getLabel('abuse-limit', 0), 'rate-time' => $route->getLabel('abuse-time', 3600), diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index 8c5bfbc348..c367656815 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -120,7 +120,7 @@ class Swagger2 extends Format $scope = $route->getLabel('scope', ''); $consumes = [$route->getLabel('sdk.request.type', 'application/json')]; - $id = $route->getLabel('sdk.method', \uniqid()); + $method = $route->getLabel('sdk.method', \uniqid()); $desc = (!empty($route->getLabel('sdk.description', ''))) ? \realpath(__DIR__ . '/../../../../' . $route->getLabel('sdk.description', '')) : null; $produces = $route->getLabel('sdk.response.type', null); $model = $route->getLabel('sdk.response.model', 'none'); @@ -151,19 +151,19 @@ class Swagger2 extends Format $temp = [ 'summary' => $route->getDesc(), - 'operationId' => $route->getLabel('sdk.namespace', 'default') . ucfirst($id), + 'operationId' => $route->getLabel('sdk.namespace', 'default') . ucfirst($method), 'consumes' => [], 'produces' => [], 'tags' => [$route->getLabel('sdk.namespace', 'default')], 'description' => ($desc) ? \file_get_contents($desc) : '', 'responses' => [], 'x-appwrite' => [ // Appwrite related metadata - 'method' => $route->getLabel('sdk.method', \uniqid()), + 'method' => $method, 'weight' => $route->getOrder(), 'cookies' => $route->getLabel('sdk.cookies', false), 'type' => $route->getLabel('sdk.methodType', ''), 'deprecated' => $route->getLabel('sdk.deprecated', false), - 'demo' => Template::fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')) . '/' . Template::fromCamelCaseToDash($id) . '.md', + 'demo' => Template::fromCamelCaseToDash($route->getLabel('sdk.namespace', 'default')) . '/' . Template::fromCamelCaseToDash($method) . '.md', 'edit' => 'https://github.com/appwrite/appwrite/edit/master' . $route->getLabel('sdk.description', ''), 'rate-limit' => $route->getLabel('abuse-limit', 0), 'rate-time' => $route->getLabel('abuse-time', 3600),