mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
fix: handle multi-method route outputs
This commit is contained in:
3 files changed
+12
-4
No files matched your search
@@ -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);
|
||||
});
|
||||
@@ -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] => [
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user