From c2645be4e1159e733a18ef2dfe54e802b79dcda4 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 18 Nov 2025 12:47:39 +0530 Subject: [PATCH 1/2] chore: custom format instance in specs --- src/Appwrite/Platform/Tasks/Specs.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index 53cbced174..c69558d096 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -43,6 +43,15 @@ class Specs extends Action return new AppwriteResponse(new SwooleResponse()); } + protected function getFormatInstance(string $format, array $arguments) + { + return match ($format) { + 'swagger2' => new Swagger2(...$arguments), + 'open-api3' => new OpenAPI3(...$arguments), + default => throw new Exception('Format not found: ' . $format) + }; + } + public function __construct() { $this @@ -288,12 +297,7 @@ class Specs extends Action ]; foreach (['swagger2', 'open-api3'] as $format) { - $formatInstance = match ($format) { - 'swagger2' => new Swagger2(...$arguments), - 'open-api3' => new OpenAPI3(...$arguments), - default => throw new Exception('Format not found: ' . $format) - }; - + $formatInstance = $this->getFormatInstance($format, $arguments); $specs = new Specification($formatInstance); $endpoint = System::getEnv('_APP_HOME', '[HOSTNAME]'); $email = System::getEnv('_APP_SYSTEM_TEAM_EMAIL', APP_EMAIL_TEAM); From 5a8a900b1881f9e898750afd36d6aa77b1c53821 Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Tue, 18 Nov 2025 12:50:22 +0530 Subject: [PATCH 2/2] format --- src/Appwrite/Platform/Tasks/Specs.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Appwrite/Platform/Tasks/Specs.php b/src/Appwrite/Platform/Tasks/Specs.php index c69558d096..edb1fc56ed 100644 --- a/src/Appwrite/Platform/Tasks/Specs.php +++ b/src/Appwrite/Platform/Tasks/Specs.php @@ -44,13 +44,13 @@ class Specs extends Action } protected function getFormatInstance(string $format, array $arguments) - { - return match ($format) { - 'swagger2' => new Swagger2(...$arguments), - 'open-api3' => new OpenAPI3(...$arguments), - default => throw new Exception('Format not found: ' . $format) - }; - } + { + return match ($format) { + 'swagger2' => new Swagger2(...$arguments), + 'open-api3' => new OpenAPI3(...$arguments), + default => throw new Exception('Format not found: ' . $format) + }; + } public function __construct() {