From 7c47add5be7dc50553a03dedc8715c5fbb57d4a4 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 14 Jul 2026 13:34:46 +0530 Subject: [PATCH 1/2] fix: generate unique SDK names for multi-method routes --- src/Appwrite/SDK/Specification/Format/OpenAPI3.php | 11 +++++++++-- tests/unit/SDK/Specification/FormatTest.php | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index 499c5c3474..ead6542848 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -833,10 +833,17 @@ class OpenAPI3 extends Format } $methods = $route->getMethods(); - foreach ($methods as $method) { + foreach ($methods as $index => $method) { $methodTemp = $temp; if (\count($methods) > 1) { - $methodTemp['operationId'] .= \ucfirst(\strtolower($method)); + $suffix = \ucfirst(\strtolower($method)); + $methodTemp['operationId'] .= $suffix; + + // Keep the first method's SDK name stable while ensuring + // additional HTTP methods generate unique SDK methods. + if ($index > 0) { + $methodTemp['x-appwrite']['method'] .= $suffix; + } } $body = [ 'content' => [ diff --git a/tests/unit/SDK/Specification/FormatTest.php b/tests/unit/SDK/Specification/FormatTest.php index 4932022c56..87f555b35a 100644 --- a/tests/unit/SDK/Specification/FormatTest.php +++ b/tests/unit/SDK/Specification/FormatTest.php @@ -188,6 +188,8 @@ final class FormatTest extends TestCase $this->assertSame('testGetOrUpdateTestGet', $get['operationId']); $this->assertSame('testGetOrUpdateTestPost', $post['operationId']); + $this->assertSame('getOrUpdateTest', $get['x-appwrite']['method']); + $this->assertSame('getOrUpdateTestPost', $post['x-appwrite']['method']); $this->assertSame('path', $get['parameters'][0]['in']); $this->assertSame('query', $get['parameters'][1]['in']); $this->assertArrayNotHasKey('requestBody', $get); From 8bf52536cedc4300fd5a2448e0a6d60901f173bd Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 14 Jul 2026 13:41:41 +0530 Subject: [PATCH 2/2] fix: normalize multi-method route indexes --- src/Appwrite/SDK/Specification/Format/OpenAPI3.php | 2 +- tests/unit/SDK/Specification/FormatTest.php | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index ead6542848..a308974f3e 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -832,7 +832,7 @@ class OpenAPI3 extends Format $url = \implode('/', $segments); } - $methods = $route->getMethods(); + $methods = \array_values($route->getMethods()); foreach ($methods as $index => $method) { $methodTemp = $temp; if (\count($methods) > 1) { diff --git a/tests/unit/SDK/Specification/FormatTest.php b/tests/unit/SDK/Specification/FormatTest.php index 87f555b35a..4b7edf0c28 100644 --- a/tests/unit/SDK/Specification/FormatTest.php +++ b/tests/unit/SDK/Specification/FormatTest.php @@ -168,7 +168,12 @@ final class FormatTest extends TestCase Method::$processed = []; Method::$errors = []; - $route = (new Route(['GET', 'POST'], '/v1/tests/:testId')) + $route = (new class (['GET', 'POST'], '/v1/tests/:testId') extends Route { + public function getMethods(): array + { + return [2 => 'GET', 4 => 'POST']; + } + }) ->desc('Get or update test') ->label('sdk', new Method( namespace: 'test',