From 24229c63ea433009904bf7aa6903bef0c031ed20 Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 5 May 2025 23:26:59 +1200 Subject: [PATCH] Fix multi-method graphql parameter mapping --- app/config/specs/open-api3-1.6.x-client.json | 2 +- app/config/specs/open-api3-1.6.x-console.json | 2 +- app/config/specs/open-api3-1.6.x-server.json | 2 +- app/config/specs/open-api3-latest-client.json | 2 +- app/config/specs/open-api3-latest-console.json | 2 +- app/config/specs/open-api3-latest-server.json | 2 +- app/config/specs/swagger2-1.6.x-client.json | 2 +- app/config/specs/swagger2-1.6.x-console.json | 2 +- app/config/specs/swagger2-1.6.x-server.json | 2 +- app/config/specs/swagger2-latest-client.json | 2 +- app/config/specs/swagger2-latest-console.json | 2 +- app/config/specs/swagger2-latest-server.json | 2 +- src/Appwrite/GraphQL/Types/Mapper.php | 14 ++++++++++---- src/Appwrite/SDK/Parameter.php | 2 +- src/Appwrite/SDK/Specification/Format/OpenAPI3.php | 2 +- src/Appwrite/SDK/Specification/Format/Swagger2.php | 2 +- 16 files changed, 25 insertions(+), 19 deletions(-) diff --git a/app/config/specs/open-api3-1.6.x-client.json b/app/config/specs/open-api3-1.6.x-client.json index 3cb2c5276b..8cc9129dee 100644 --- a/app/config/specs/open-api3-1.6.x-client.json +++ b/app/config/specs/open-api3-1.6.x-client.json @@ -4555,7 +4555,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "x-example": null, "items": { "type": "object" diff --git a/app/config/specs/open-api3-1.6.x-console.json b/app/config/specs/open-api3-1.6.x-console.json index 2bbaa9bcf2..1b0dc1c247 100644 --- a/app/config/specs/open-api3-1.6.x-console.json +++ b/app/config/specs/open-api3-1.6.x-console.json @@ -8046,7 +8046,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "x-example": null, "items": { "type": "object" diff --git a/app/config/specs/open-api3-1.6.x-server.json b/app/config/specs/open-api3-1.6.x-server.json index bcc780ded6..7d8f6bd09f 100644 --- a/app/config/specs/open-api3-1.6.x-server.json +++ b/app/config/specs/open-api3-1.6.x-server.json @@ -7597,7 +7597,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "x-example": null, "items": { "type": "object" diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index 3cb2c5276b..8cc9129dee 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -4555,7 +4555,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "x-example": null, "items": { "type": "object" diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 2bbaa9bcf2..1b0dc1c247 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -8046,7 +8046,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "x-example": null, "items": { "type": "object" diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index bcc780ded6..7d8f6bd09f 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -7597,7 +7597,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "x-example": null, "items": { "type": "object" diff --git a/app/config/specs/swagger2-1.6.x-client.json b/app/config/specs/swagger2-1.6.x-client.json index 12c3ff1b7f..308895a819 100644 --- a/app/config/specs/swagger2-1.6.x-client.json +++ b/app/config/specs/swagger2-1.6.x-client.json @@ -4692,7 +4692,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "default": [], "x-example": null, "items": { diff --git a/app/config/specs/swagger2-1.6.x-console.json b/app/config/specs/swagger2-1.6.x-console.json index 46d071b844..3c9d98b0c7 100644 --- a/app/config/specs/swagger2-1.6.x-console.json +++ b/app/config/specs/swagger2-1.6.x-console.json @@ -8174,7 +8174,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "default": [], "x-example": null, "items": { diff --git a/app/config/specs/swagger2-1.6.x-server.json b/app/config/specs/swagger2-1.6.x-server.json index e7dcfc707e..7119a8f584 100644 --- a/app/config/specs/swagger2-1.6.x-server.json +++ b/app/config/specs/swagger2-1.6.x-server.json @@ -7713,7 +7713,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "default": [], "x-example": null, "items": { diff --git a/app/config/specs/swagger2-latest-client.json b/app/config/specs/swagger2-latest-client.json index 12c3ff1b7f..308895a819 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -4692,7 +4692,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "default": [], "x-example": null, "items": { diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 46d071b844..3c9d98b0c7 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -8174,7 +8174,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "default": [], "x-example": null, "items": { diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index e7dcfc707e..7119a8f584 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -7713,7 +7713,7 @@ }, "documents": { "type": "array", - "description": "Array of documents data as JSON object.", + "description": "Array of documents data as JSON objects.", "default": [], "x-example": null, "items": { diff --git a/src/Appwrite/GraphQL/Types/Mapper.php b/src/Appwrite/GraphQL/Types/Mapper.php index e5056d0abc..0acd0881ae 100644 --- a/src/Appwrite/GraphQL/Types/Mapper.php +++ b/src/Appwrite/GraphQL/Types/Mapper.php @@ -117,13 +117,19 @@ class Mapper $list = false; foreach ($route->getParams() as $name => $parameter) { - $methodParameters = $method->getParameters(); + $sdkParameters = $method->getParameters(); - if (!empty($methodParameters)) { - if (!array_key_exists($name, $methodParameters)) { + if (!empty($sdkParameters)) { + $sdkMethodParameters = []; + foreach($sdkParameters as $sdkParameter) { + $sdkMethodParameters[$sdkParameter->getName()] = $sdkParameter; + } + + if (!\array_key_exists($name, $sdkMethodParameters)) { continue; } - $optional = $methodParameters[$name]['optional']; + + $optional = $sdkMethodParameters[$name]->getOptional(); } else { $optional = $parameter['optional']; } diff --git a/src/Appwrite/SDK/Parameter.php b/src/Appwrite/SDK/Parameter.php index cf46e2475a..57d061925e 100644 --- a/src/Appwrite/SDK/Parameter.php +++ b/src/Appwrite/SDK/Parameter.php @@ -62,7 +62,7 @@ class Parameter $this->validator = $validator; } - public function isOptional(): bool + public function getOptional(): bool { return $this->optional; } diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index 68db229c44..36c1e74c85 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -184,7 +184,7 @@ class OpenAPI3 extends Format foreach ($method->getParameters() as $parameter) { $additionalMethod['parameters'][] = $parameter->getName(); - if (!$parameter->isOptional()) { + if (!$parameter->getOptional()) { $additionalMethod['required'][] = $parameter->getName(); } } diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index 2d55cf6d33..e5b7906b3f 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -190,7 +190,7 @@ class Swagger2 extends Format foreach ($method->getParameters() as $parameter) { $additionalMethod['parameters'][] = $parameter->getName(); - if (!$parameter->isOptional()) { + if (!$parameter->getOptional()) { $additionalMethod['required'][] = $parameter->getName(); } }