From 529847df95d950afc58da5f7bd75186bb804f703 Mon Sep 17 00:00:00 2001 From: harsh mahajan Date: Fri, 5 Jun 2026 18:02:18 +0530 Subject: [PATCH] refactor: add locationAuth to Method.php, use getLocationAuth() in spec formatters --- src/Appwrite/SDK/Method.php | 9 ++++++++- src/Appwrite/SDK/Specification/Format/OpenAPI3.php | 2 +- src/Appwrite/SDK/Specification/Format/Swagger2.php | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Appwrite/SDK/Method.php b/src/Appwrite/SDK/Method.php index 5f6ccf9a0f..97283dfb4a 100644 --- a/src/Appwrite/SDK/Method.php +++ b/src/Appwrite/SDK/Method.php @@ -33,6 +33,7 @@ class Method * @param string $desc * @param bool $public Whether this method should be rendered on the website/documentation * @param string $projectAuth Project authentication security scheme to use in specs + * @param array $locationAuth Additional security scheme keys injected for location-type methods */ public function __construct( protected string $namespace, @@ -51,7 +52,8 @@ class Method protected array $additionalParameters = [], protected string $desc = '', protected bool $public = true, - protected string $projectAuth = 'Project' + protected string $projectAuth = 'Project', + protected array $locationAuth = ['ImpersonateUserIdQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'] ) { $this->validateMethod($name, $namespace); $this->validateAuthTypes($auth); @@ -234,6 +236,11 @@ class Method return $this->projectAuth; } + public function getLocationAuth(): array + { + return $this->locationAuth; + } + public function setNamespace(string $namespace): self { $this->namespace = $namespace; diff --git a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php index c40c44b85e..cf83c3ea96 100644 --- a/src/Appwrite/SDK/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/SDK/Specification/Format/OpenAPI3.php @@ -386,7 +386,7 @@ class OpenAPI3 extends Format $temp['x-appwrite']['auth'] = array_slice($securities, 0, $this->authCount); if ($sdk->getType() === MethodType::LOCATION) { - foreach (['ImpersonateUserIdQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'] as $key) { + foreach ($sdk->getLocationAuth() as $key) { if (\array_key_exists($key, $this->keys)) { $securities[$key] = []; $temp['x-appwrite']['auth'][$key] = []; diff --git a/src/Appwrite/SDK/Specification/Format/Swagger2.php b/src/Appwrite/SDK/Specification/Format/Swagger2.php index ca2643222a..0c4c423de1 100644 --- a/src/Appwrite/SDK/Specification/Format/Swagger2.php +++ b/src/Appwrite/SDK/Specification/Format/Swagger2.php @@ -376,7 +376,7 @@ class Swagger2 extends Format $temp['x-appwrite']['auth'] = \array_slice($securities, 0, $this->authCount); if ($sdk->getType() === MethodType::LOCATION) { - foreach (['ImpersonateUserIdQuery', 'ImpersonateUserEmailQuery', 'ImpersonateUserPhoneQuery'] as $key) { + foreach ($sdk->getLocationAuth() as $key) { if (\array_key_exists($key, $this->keys)) { $securities[$key] = []; $temp['x-appwrite']['auth'][$key] = [];