fix: handle multi-method route outputs

This commit is contained in:
Chirag Aggarwal committed 2026-07-14 09:52:28 +05:30
1 parent aca1dfc883
commit 10d246519e
3 files changed
+12 -4

No files matched your search

+5 -3
View File
@@ -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);