mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #12871 from appwrite/fix-multi-method-sdk-names
Fix duplicate SDK methods for multi-method routes
This commit is contained in:
2 files changed
+18
-4
No files matched your search
@@ -832,11 +832,18 @@ class OpenAPI3 extends Format
|
||||
$url = \implode('/', $segments);
|
||||
}
|
||||
|
||||
$methods = $route->getMethods();
|
||||
foreach ($methods as $method) {
|
||||
$methods = \array_values($route->getMethods());
|
||||
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' => [
|
||||
|
||||
@@ -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',
|
||||
@@ -188,6 +193,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);
|
||||
|
||||
Reference in new issue
Block a user