fix: generate unique SDK names for multi-method routes

This commit is contained in:
Chirag Aggarwal committed 2026-07-14 13:34:46 +05:30
1 parent 699d8d0529
commit 7c47add5be
2 files changed
+11 -2

No files matched your search

@@ -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' => [
@@ -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);