refactor: add locationAuth to Method.php, use getLocationAuth() in spec formatters

This commit is contained in:
harsh mahajan committed 2026-06-05 18:02:18 +05:30
1 parent 18dfaedc37
commit 529847df95
3 files changed
+10 -3

No files matched your search

+8 -1
View File
@@ -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<string> $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;
@@ -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] = [];
@@ -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] = [];