diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 97c032720a..f7cbca76a5 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -28250,9 +28250,7 @@ "yammer", "yandex", "zoho", - "zoom", - "mock", - "mock-unverified" + "zoom" ], "x-enum-name": "OAuthProvider", "x-enum-keys": [] diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index f0e1c5608c..17064287be 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -28351,9 +28351,7 @@ "yammer", "yandex", "zoho", - "zoom", - "mock", - "mock-unverified" + "zoom" ], "x-enum-name": "OAuthProvider", "x-enum-keys": [] diff --git a/src/Appwrite/SDK/Specification/Format.php b/src/Appwrite/SDK/Specification/Format.php index 53f96d490e..ed77e568f4 100644 --- a/src/Appwrite/SDK/Specification/Format.php +++ b/src/Appwrite/SDK/Specification/Format.php @@ -40,35 +40,46 @@ abstract class Format 'license.url' => '', ]; - /* - * Blacklist to omit the enum types for the given route's parameter - */ - protected array $enumBlacklist = [ + private const array OAUTH_PROVIDER_BLACKLIST = [ + [ + 'namespace' => 'account', + 'methods' => [ + 'createOAuth2Session', + 'createOAuth2Token', + 'updateMagicURLSession' + ], + 'parameter' => 'provider', + 'excludeKeys' => [ + 'mock', + 'mock-unverified' + ], + ], + [ + 'namespace' => 'projects', + 'methods' => [ + 'updateOAuth2' + ], + 'parameter' => 'provider', + 'excludeKeys' => [ + 'mock', + 'mock-unverified' + ], + ], + ]; + + private const array PROVIDER_USAGE_BLACKLIST = [ [ 'namespace' => 'users', - 'method' => 'getUsage', - 'parameter' => 'provider' - ], - [ - 'namespace' => 'account', - 'method' => 'createOAuth2Session', + 'methods' => [ + 'getUsage' + ], 'parameter' => 'provider', - 'excludeKeys' => ['mock', 'mock-unverified'] + 'exclude' => true, /* fully excluded */ ], - [ - 'namespace' => 'account', - 'method' => 'createOAuth2Token', - 'parameter' => 'provider', - 'excludeKeys' => ['mock', 'mock-unverified'] - ], - [ - 'namespace' => 'account', - 'method' => 'updateMagicURLSession', - 'parameter' => 'provider', - 'excludeKeys' => ['mock', 'mock-unverified'] - ] ]; + protected array $enumBlacklist = []; + public function __construct(App $app, array $services, array $routes, array $models, array $keys, int $authCount, string $platform) { $this->app = $app; @@ -78,6 +89,49 @@ abstract class Format $this->keys = $keys; $this->authCount = $authCount; $this->platform = $platform; + + $this->enumBlacklist = $this->buildEnumBlacklist(); + } + + protected function buildEnumBlacklist(): array + { + $blacklist = []; + + foreach (self::OAUTH_PROVIDER_BLACKLIST as $config) { + foreach ($config['methods'] as $method) { + $entry = [ + 'namespace' => $config['namespace'], + 'method' => $method, + 'parameter' => $config['parameter'], + ]; + if (isset($config['excludeKeys'])) { + $entry['excludeKeys'] = $config['excludeKeys']; + } + if (isset($config['exclude'])) { + $entry['exclude'] = $config['exclude']; + } + $blacklist[] = $entry; + } + } + + foreach (self::PROVIDER_USAGE_BLACKLIST as $config) { + foreach ($config['methods'] as $method) { + $entry = [ + 'namespace' => $config['namespace'], + 'method' => $method, + 'parameter' => $config['parameter'], + ]; + if (isset($config['excludeKeys'])) { + $entry['excludeKeys'] = $config['excludeKeys']; + } + if (isset($config['exclude'])) { + $entry['exclude'] = $config['exclude']; + } + $blacklist[] = $entry; + } + } + + return $blacklist; } /**