mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: unwanted method being added to specs
This commit is contained in:
@@ -283,7 +283,8 @@ class Specs extends Action
|
||||
$routes,
|
||||
$models,
|
||||
$keys[$platform],
|
||||
$authCounts[$platform] ?? 0
|
||||
$authCounts[$platform] ?? 0,
|
||||
$platforms[$platform]
|
||||
];
|
||||
|
||||
foreach (['swagger2', 'open-api3'] as $format) {
|
||||
|
||||
@@ -24,6 +24,7 @@ abstract class Format
|
||||
protected array $services;
|
||||
protected array $keys;
|
||||
protected int $authCount;
|
||||
protected string $platform;
|
||||
protected array $params = [
|
||||
'name' => '',
|
||||
'description' => '',
|
||||
@@ -50,7 +51,7 @@ abstract class Format
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct(App $app, array $services, array $routes, array $models, array $keys, int $authCount)
|
||||
public function __construct(App $app, array $services, array $routes, array $models, array $keys, int $authCount, string $platform)
|
||||
{
|
||||
$this->app = $app;
|
||||
$this->services = $services;
|
||||
@@ -58,6 +59,7 @@ abstract class Format
|
||||
$this->models = $models;
|
||||
$this->keys = $keys;
|
||||
$this->authCount = $authCount;
|
||||
$this->platform = $platform;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -177,6 +177,32 @@ class OpenAPI3 extends Format
|
||||
/** @var Method $method */
|
||||
$desc = $method->getDescriptionFilePath();
|
||||
|
||||
$methodSecurities = $method->getAuth();
|
||||
$methodSdkPlatforms = [];
|
||||
foreach ($methodSecurities as $value) {
|
||||
switch ($value) {
|
||||
case AuthType::SESSION:
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_CLIENT;
|
||||
break;
|
||||
case AuthType::JWT:
|
||||
case AuthType::KEY:
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_SERVER;
|
||||
break;
|
||||
case AuthType::ADMIN:
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_CONSOLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($methodSecurities)) {
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_SERVER;
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_CLIENT;
|
||||
}
|
||||
|
||||
if ($this->platform !== APP_PLATFORM_CONSOLE && !\in_array($this->platform, $methodSdkPlatforms)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$methodSecurities = ['Project' => []];
|
||||
foreach ($method->getAuth() as $security) {
|
||||
/** @var AuthType $security */
|
||||
|
||||
@@ -183,6 +183,32 @@ class Swagger2 extends Format
|
||||
/** @var Method $method */
|
||||
$desc = $method->getDescriptionFilePath();
|
||||
|
||||
$methodSecurities = $method->getAuth();
|
||||
$methodSdkPlatforms = [];
|
||||
foreach ($methodSecurities as $value) {
|
||||
switch ($value) {
|
||||
case AuthType::SESSION:
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_CLIENT;
|
||||
break;
|
||||
case AuthType::JWT:
|
||||
case AuthType::KEY:
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_SERVER;
|
||||
break;
|
||||
case AuthType::ADMIN:
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_CONSOLE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($methodSecurities)) {
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_SERVER;
|
||||
$methodSdkPlatforms[] = APP_PLATFORM_CLIENT;
|
||||
}
|
||||
|
||||
if ($this->platform !== APP_PLATFORM_CONSOLE && !\in_array($this->platform, $methodSdkPlatforms)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$methodSecurities = ['Project' => []];
|
||||
foreach ($method->getAuth() as $security) {
|
||||
/** @var AuthType $security */
|
||||
|
||||
Reference in New Issue
Block a user