diff --git a/app/controllers/mock.php b/app/controllers/mock.php index 34f5d67d85..40bd55c5fa 100644 --- a/app/controllers/mock.php +++ b/app/controllers/mock.php @@ -303,13 +303,15 @@ Http::shutdown() $result = []; $path = APP_STORAGE_CACHE . '/tests.json'; $tests = (\file_exists($path)) ? \json_decode(\file_get_contents($path), true) : []; - $methods = \implode(',', $route->getMethods()); + $methods = $route->getMethods(); if (!\is_array($tests)) { throw new Exception(Exception::GENERAL_MOCK, 'Failed to read results', 500); } - $result[$methods . ':' . $route->getPath()] = true; + foreach ($methods as $method) { + $result[$method . ':' . $route->getPath()] = true; + } $tests = \array_merge($tests, $result); @@ -317,5 +319,5 @@ Http::shutdown() throw new Exception(Exception::GENERAL_MOCK, 'Failed to save results', 500); } - $response->dynamic(new Document(['result' => $methods . ':' . $route->getPath() . ':passed']), Response::MODEL_MOCK); + $response->dynamic(new Document(['result' => \implode(',', $methods) . ':' . $route->getPath() . ':passed']), Response::MODEL_MOCK); }); diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index ffcf833035..499c5c3474 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -832,8 +832,12 @@ class OpenAPI3 extends Format $url = \implode('/', $segments); } - foreach ($route->getMethods() as $method) { + $methods = $route->getMethods(); + foreach ($methods as $method) { $methodTemp = $temp; + if (\count($methods) > 1) { + $methodTemp['operationId'] .= \ucfirst(\strtolower($method)); + } $body = [ 'content' => [ $consumes[0] => [ diff --git a/tests/unit/SDK/Specification/FormatTest.php b/tests/unit/SDK/Specification/FormatTest.php index 1d500ff048..4932022c56 100644 --- a/tests/unit/SDK/Specification/FormatTest.php +++ b/tests/unit/SDK/Specification/FormatTest.php @@ -186,6 +186,8 @@ final class FormatTest extends TestCase $get = $openApi['paths']['/tests/{testId}']['get']; $post = $openApi['paths']['/tests/{testId}']['post']; + $this->assertSame('testGetOrUpdateTestGet', $get['operationId']); + $this->assertSame('testGetOrUpdateTestPost', $post['operationId']); $this->assertSame('path', $get['parameters'][0]['in']); $this->assertSame('query', $get['parameters'][1]['in']); $this->assertArrayNotHasKey('requestBody', $get);