mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
Remove redundant spec platform helpers
This commit is contained in:
@@ -514,25 +514,6 @@ abstract class Format
|
||||
return \array_slice($securities, 0, $authCount);
|
||||
}
|
||||
|
||||
protected function includesTargetPlatform(array $platforms): bool
|
||||
{
|
||||
return !empty(\array_intersect($this->targetPlatforms, $platforms));
|
||||
}
|
||||
|
||||
protected function isMultiPlatformSpec(): bool
|
||||
{
|
||||
return \count($this->targetPlatforms) > 1;
|
||||
}
|
||||
|
||||
protected function getIncludedPlatforms(array $platforms): array
|
||||
{
|
||||
if (!$this->isMultiPlatformSpec()) {
|
||||
return \array_values(\array_unique($platforms));
|
||||
}
|
||||
|
||||
return \array_values(\array_intersect($this->targetPlatforms, $platforms));
|
||||
}
|
||||
|
||||
protected function getRequestEnumName(string $service, string $method, string $param): ?string
|
||||
{
|
||||
/* `$service` is `$namespace` */
|
||||
|
||||
@@ -146,7 +146,9 @@ class OpenAPI3 extends Format
|
||||
'rate-time' => $route->getLabel('abuse-time', 3600),
|
||||
'rate-key' => $route->getLabel('abuse-key', 'url:{url},ip:{ip}'),
|
||||
'scope' => $route->getLabel('scope', ''),
|
||||
'platforms' => $this->getIncludedPlatforms($sdkPlatforms),
|
||||
'platforms' => \count($this->targetPlatforms) > 1
|
||||
? \array_values(\array_intersect($this->targetPlatforms, $sdkPlatforms))
|
||||
: \array_values(\array_unique($sdkPlatforms)),
|
||||
'packaging' => $sdk->isPackaging(),
|
||||
'public' => $sdk->isPublic(),
|
||||
],
|
||||
@@ -172,12 +174,10 @@ class OpenAPI3 extends Format
|
||||
$methodSecurities = $methodObj->getAuth();
|
||||
$methodSdkPlatforms = $specs->getSDKPlatformsForRouteSecurity($methodSecurities);
|
||||
|
||||
if (!$this->includesTargetPlatform($methodSdkPlatforms)) {
|
||||
if (empty(\array_intersect($this->targetPlatforms, $methodSdkPlatforms))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$methodSecurities = $this->getSecurityForPlatform($methodObj->getAuth(), $this->platform);
|
||||
|
||||
$additionalMethod = [
|
||||
'name' => $methodObj->getMethodName(),
|
||||
'namespace' => $methodObj->getNamespace(),
|
||||
@@ -190,11 +190,11 @@ class OpenAPI3 extends Format
|
||||
'public' => $methodObj->isPublic(),
|
||||
];
|
||||
|
||||
if ($this->isMultiPlatformSpec()) {
|
||||
$additionalMethod['platforms'] = $this->getIncludedPlatforms($methodSdkPlatforms);
|
||||
if (\count($this->targetPlatforms) > 1) {
|
||||
$additionalMethod['platforms'] = \array_values(\array_intersect($this->targetPlatforms, $methodSdkPlatforms));
|
||||
$additionalMethod['platformSecurity'] = $this->getPlatformSecurity($methodObj->getAuth(), $methodSdkPlatforms);
|
||||
} else {
|
||||
$additionalMethod['auth'] = $methodSecurities;
|
||||
$additionalMethod['auth'] = $this->getSecurityForPlatform($methodObj->getAuth(), $this->platform);
|
||||
}
|
||||
|
||||
// add deprecation only if method has it!
|
||||
@@ -372,7 +372,7 @@ class OpenAPI3 extends Format
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isMultiPlatformSpec()) {
|
||||
if (\count($this->targetPlatforms) > 1) {
|
||||
$temp['x-appwrite']['platformSecurity'] = $this->getPlatformSecurity($sdk->getAuth(), $sdkPlatforms);
|
||||
} else {
|
||||
$temp['x-appwrite']['auth'] = array_slice($securities, 0, $this->authCount);
|
||||
|
||||
@@ -149,7 +149,9 @@ class Swagger2 extends Format
|
||||
'rate-time' => $route->getLabel('abuse-time', 3600),
|
||||
'rate-key' => $route->getLabel('abuse-key', 'url:{url},ip:{ip}'),
|
||||
'scope' => $route->getLabel('scope', ''),
|
||||
'platforms' => $this->getIncludedPlatforms($sdkPlatforms),
|
||||
'platforms' => \count($this->targetPlatforms) > 1
|
||||
? \array_values(\array_intersect($this->targetPlatforms, $sdkPlatforms))
|
||||
: \array_values(\array_unique($sdkPlatforms)),
|
||||
'packaging' => $sdk->isPackaging(),
|
||||
'public' => $sdk->isPublic(),
|
||||
],
|
||||
@@ -179,12 +181,10 @@ class Swagger2 extends Format
|
||||
$methodSecurities = $methodObj->getAuth();
|
||||
$methodSdkPlatforms = $specs->getSDKPlatformsForRouteSecurity($methodSecurities);
|
||||
|
||||
if (!$this->includesTargetPlatform($methodSdkPlatforms)) {
|
||||
if (empty(\array_intersect($this->targetPlatforms, $methodSdkPlatforms))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$methodSecurities = $this->getSecurityForPlatform($methodObj->getAuth(), $this->platform);
|
||||
|
||||
$additionalMethod = [
|
||||
'name' => $methodObj->getMethodName(),
|
||||
'namespace' => $methodObj->getNamespace(),
|
||||
@@ -197,11 +197,11 @@ class Swagger2 extends Format
|
||||
'public' => $methodObj->isPublic(),
|
||||
];
|
||||
|
||||
if ($this->isMultiPlatformSpec()) {
|
||||
$additionalMethod['platforms'] = $this->getIncludedPlatforms($methodSdkPlatforms);
|
||||
if (\count($this->targetPlatforms) > 1) {
|
||||
$additionalMethod['platforms'] = \array_values(\array_intersect($this->targetPlatforms, $methodSdkPlatforms));
|
||||
$additionalMethod['platformSecurity'] = $this->getPlatformSecurity($methodObj->getAuth(), $methodSdkPlatforms);
|
||||
} else {
|
||||
$additionalMethod['auth'] = $methodSecurities;
|
||||
$additionalMethod['auth'] = $this->getSecurityForPlatform($methodObj->getAuth(), $this->platform);
|
||||
}
|
||||
|
||||
// add deprecation only if method has it!
|
||||
@@ -368,7 +368,7 @@ class Swagger2 extends Format
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->isMultiPlatformSpec()) {
|
||||
if (\count($this->targetPlatforms) > 1) {
|
||||
$temp['x-appwrite']['platformSecurity'] = $this->getPlatformSecurity($sdk->getAuth(), $sdkPlatforms);
|
||||
} else {
|
||||
$temp['x-appwrite']['auth'] = \array_slice($securities, 0, $this->authCount);
|
||||
|
||||
Reference in New Issue
Block a user