mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
chore: browser permissions enum
This commit is contained in:
@@ -171,6 +171,12 @@ abstract class Format
|
||||
return 'CreditCard';
|
||||
case 'getFlag':
|
||||
return 'Flag';
|
||||
case 'getScreenshot':
|
||||
switch ($param) {
|
||||
case 'permissions':
|
||||
return 'BrowserPermission';
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'databases':
|
||||
|
||||
@@ -19,7 +19,6 @@ use Utopia\Validator;
|
||||
use Utopia\Validator\ArrayList;
|
||||
use Utopia\Validator\Nullable;
|
||||
use Utopia\Validator\Range;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
class OpenAPI3 extends Format
|
||||
{
|
||||
@@ -440,6 +439,7 @@ class OpenAPI3 extends Format
|
||||
$subclass = \get_class($validator->getValidator());
|
||||
switch ($subclass) {
|
||||
case 'Appwrite\Utopia\Database\Validator\Operation':
|
||||
case 'Utopia\Validator\WhiteList':
|
||||
$class = $subclass;
|
||||
break;
|
||||
}
|
||||
@@ -601,30 +601,63 @@ class OpenAPI3 extends Format
|
||||
}
|
||||
break;
|
||||
case 'Utopia\Validator\WhiteList':
|
||||
/** @var WhiteList $validator */
|
||||
$node['schema']['type'] = $validator->getType();
|
||||
$node['schema']['x-example'] = ($param['example'] ?? '') ?: $validator->getList()[0];
|
||||
if ($array) {
|
||||
$validator = $validator->getValidator();
|
||||
|
||||
// Iterate from the blackList. If it matches with the current one, then it is a blackList
|
||||
// Do not add the enum
|
||||
$allowed = true;
|
||||
foreach ($this->enumBlacklist as $blacklist) {
|
||||
if (
|
||||
$blacklist['namespace'] == $sdk->getNamespace()
|
||||
&& $blacklist['method'] == $methodName
|
||||
&& $blacklist['parameter'] == $name
|
||||
) {
|
||||
$allowed = false;
|
||||
break;
|
||||
$node['schema']['type'] = 'array';
|
||||
$node['schema']['items'] = [
|
||||
'type' => $validator->getType(),
|
||||
];
|
||||
if (!empty($param['example'])) {
|
||||
$node['schema']['x-example'] = $param['example'];
|
||||
}
|
||||
|
||||
// Iterate from the blackList. If it matches with the current one, then it is a blackList
|
||||
// Do not add the enum
|
||||
$allowed = true;
|
||||
foreach ($this->enumBlacklist as $blacklist) {
|
||||
if (
|
||||
$blacklist['namespace'] == $sdk->getNamespace()
|
||||
&& $blacklist['method'] == $methodName
|
||||
&& $blacklist['parameter'] == $name
|
||||
) {
|
||||
$allowed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($allowed && $validator->getType() === 'string') {
|
||||
$node['schema']['items']['enum'] = $validator->getList();
|
||||
$node['schema']['items']['x-enum-name'] = $this->getRequestEnumName($sdk->getNamespace() ?? '', $methodName, $name);
|
||||
$node['schema']['items']['x-enum-keys'] = $this->getRequestEnumKeys($sdk->getNamespace() ?? '', $methodName, $name);
|
||||
}
|
||||
if ($validator->getType() === 'integer') {
|
||||
$node['schema']['items']['format'] = 'int32';
|
||||
}
|
||||
} else {
|
||||
$node['schema']['type'] = $validator->getType();
|
||||
$node['schema']['x-example'] = ($param['example'] ?? '') ?: $validator->getList()[0];
|
||||
|
||||
// Iterate from the blackList. If it matches with the current one, then it is a blackList
|
||||
// Do not add the enum
|
||||
$allowed = true;
|
||||
foreach ($this->enumBlacklist as $blacklist) {
|
||||
if (
|
||||
$blacklist['namespace'] == $sdk->getNamespace()
|
||||
&& $blacklist['method'] == $methodName
|
||||
&& $blacklist['parameter'] == $name
|
||||
) {
|
||||
$allowed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($allowed && $validator->getType() === 'string') {
|
||||
$node['schema']['enum'] = $validator->getList();
|
||||
$node['schema']['x-enum-name'] = $this->getRequestEnumName($sdk->getNamespace() ?? '', $methodName, $name);
|
||||
$node['schema']['x-enum-keys'] = $this->getRequestEnumKeys($sdk->getNamespace() ?? '', $methodName, $name);
|
||||
}
|
||||
if ($validator->getType() === 'integer') {
|
||||
$node['format'] = 'int32';
|
||||
}
|
||||
}
|
||||
if ($allowed && $validator->getType() === 'string') {
|
||||
$node['schema']['enum'] = $validator->getList();
|
||||
$node['schema']['x-enum-name'] = $this->getRequestEnumName($sdk->getNamespace() ?? '', $methodName, $name);
|
||||
$node['schema']['x-enum-keys'] = $this->getRequestEnumKeys($sdk->getNamespace() ?? '', $methodName, $name);
|
||||
}
|
||||
if ($validator->getType() === 'integer') {
|
||||
$node['format'] = 'int32';
|
||||
}
|
||||
break;
|
||||
case 'Appwrite\Utopia\Database\Validator\CompoundUID':
|
||||
|
||||
@@ -20,7 +20,6 @@ use Utopia\Validator;
|
||||
use Utopia\Validator\ArrayList;
|
||||
use Utopia\Validator\Nullable;
|
||||
use Utopia\Validator\Range;
|
||||
use Utopia\Validator\WhiteList;
|
||||
|
||||
class Swagger2 extends Format
|
||||
{
|
||||
@@ -445,6 +444,7 @@ class Swagger2 extends Format
|
||||
$subclass = \get_class($validator->getValidator());
|
||||
switch ($subclass) {
|
||||
case 'Appwrite\Utopia\Database\Validator\Operation':
|
||||
case 'Utopia\Validator\WhiteList':
|
||||
$class = $subclass;
|
||||
break;
|
||||
}
|
||||
@@ -590,25 +590,54 @@ class Swagger2 extends Format
|
||||
}
|
||||
break;
|
||||
case 'Utopia\Validator\WhiteList':
|
||||
/** @var WhiteList $validator */
|
||||
$node['type'] = $validator->getType();
|
||||
$node['x-example'] = ($param['example'] ?? '') ?: $validator->getList()[0];
|
||||
if ($array) {
|
||||
$validator = $validator->getValidator();
|
||||
|
||||
// Iterate the blackList. If it matches with the current one, then it is blackListed
|
||||
$allowed = true;
|
||||
foreach ($this->enumBlacklist as $blacklist) {
|
||||
if ($blacklist['namespace'] == $namespace && $blacklist['method'] == $methodName && $blacklist['parameter'] == $name) {
|
||||
$allowed = false;
|
||||
break;
|
||||
$node['type'] = 'array';
|
||||
$node['collectionFormat'] = 'multi';
|
||||
$node['items'] = [
|
||||
'type' => $validator->getType(),
|
||||
];
|
||||
if (!empty($param['example'])) {
|
||||
$node['x-example'] = $param['example'];
|
||||
}
|
||||
|
||||
// Iterate the blackList. If it matches with the current one, then it is blackListed
|
||||
$allowed = true;
|
||||
foreach ($this->enumBlacklist as $blacklist) {
|
||||
if ($blacklist['namespace'] == $namespace && $blacklist['method'] == $methodName && $blacklist['parameter'] == $name) {
|
||||
$allowed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($allowed && $validator->getType() === 'string') {
|
||||
$node['items']['enum'] = $validator->getList();
|
||||
$node['items']['x-enum-name'] = $this->getRequestEnumName($namespace, $methodName, $name);
|
||||
$node['items']['x-enum-keys'] = $this->getRequestEnumKeys($namespace, $methodName, $name);
|
||||
}
|
||||
if ($validator->getType() === 'integer') {
|
||||
$node['items']['format'] = 'int32';
|
||||
}
|
||||
} else {
|
||||
$node['type'] = $validator->getType();
|
||||
$node['x-example'] = ($param['example'] ?? '') ?: $validator->getList()[0];
|
||||
|
||||
// Iterate the blackList. If it matches with the current one, then it is blackListed
|
||||
$allowed = true;
|
||||
foreach ($this->enumBlacklist as $blacklist) {
|
||||
if ($blacklist['namespace'] == $namespace && $blacklist['method'] == $methodName && $blacklist['parameter'] == $name) {
|
||||
$allowed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($allowed && $validator->getType() === 'string') {
|
||||
$node['enum'] = $validator->getList();
|
||||
$node['x-enum-name'] = $this->getRequestEnumName($namespace, $methodName, $name);
|
||||
$node['x-enum-keys'] = $this->getRequestEnumKeys($namespace, $methodName, $name);
|
||||
}
|
||||
if ($validator->getType() === 'integer') {
|
||||
$node['format'] = 'int32';
|
||||
}
|
||||
}
|
||||
if ($allowed && $validator->getType() === 'string') {
|
||||
$node['enum'] = $validator->getList();
|
||||
$node['x-enum-name'] = $this->getRequestEnumName($namespace, $methodName, $name);
|
||||
$node['x-enum-keys'] = $this->getRequestEnumKeys($namespace, $methodName, $name);
|
||||
}
|
||||
if ($validator->getType() === 'integer') {
|
||||
$node['format'] = 'int32';
|
||||
}
|
||||
break;
|
||||
case 'Appwrite\Utopia\Database\Validator\CompoundUID':
|
||||
|
||||
Reference in New Issue
Block a user