Merge branch 'feat-database-update-attribute' of github.com:appwrite/appwrite into feat-relations-2

 Conflicts:
	app/controllers/api/databases.php
	composer.json
	composer.lock
This commit is contained in:
fogelito
2023-03-16 12:14:37 +02:00
35 changed files with 2934 additions and 272 deletions
+1
View File
@@ -146,6 +146,7 @@ class Exception extends \Exception
public const ATTRIBUTE_ALREADY_EXISTS = 'attribute_already_exists';
public const ATTRIBUTE_LIMIT_EXCEEDED = 'attribute_limit_exceeded';
public const ATTRIBUTE_VALUE_INVALID = 'attribute_value_invalid';
public const ATTRIBUTE_TYPE_INVALID = 'attribute_type_invalid';
/** Indexes */
public const INDEX_NOT_FOUND = 'index_not_found';
+8 -4
View File
@@ -11,6 +11,7 @@ use GraphQL\Type\Definition\UnionType;
use Utopia\App;
use Utopia\Route;
use Utopia\Validator;
use Utopia\Validator\Nullable;
class Mapper
{
@@ -109,9 +110,6 @@ class Mapper
'type' => $parameterType,
'description' => $parameter['description'],
];
if ($parameter['optional']) {
$params[$name]['defaultValue'] = $parameter['default'];
}
}
$field = [
@@ -224,6 +222,12 @@ class Mapper
? \call_user_func_array($validator, $utopia->getResources($injections))
: $validator;
$isNullable = $validator instanceof Nullable;
if ($isNullable) {
$validator = $validator->getValidator();
}
switch ((!empty($validator)) ? $validator::class : '') {
case 'Appwrite\Network\Validator\CNAME':
case 'Appwrite\Task\Validator\Cron':
@@ -294,7 +298,7 @@ class Mapper
break;
}
if ($required) {
if ($required && !$isNullable) {
$type = Type::nonNull($type);
}
@@ -8,6 +8,7 @@ use Appwrite\Utopia\Response\Model;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Validator;
use Utopia\Validator\Nullable;
class OpenAPI3 extends Format
{
@@ -284,6 +285,13 @@ class OpenAPI3 extends Format
}
}
$isNullable = $validator instanceof Nullable;
if ($isNullable) {
/** @var Nullable $validator */
$validator = $validator->getValidator();
}
switch ((!empty($validator)) ? \get_class($validator) : '') {
case 'Utopia\Validator\Text':
$node['schema']['type'] = $validator->getType();
@@ -449,6 +457,10 @@ class OpenAPI3 extends Format
if ($node['x-global'] ?? false) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-global'] = true;
}
if ($isNullable) {
$body['content'][$consumes[0]]['schema']['properties'][$name]['x-nullable'] = true;
}
}
$url = \str_replace(':' . $name, '{' . $name . '}', $url);
@@ -8,6 +8,7 @@ use Appwrite\Utopia\Response\Model;
use Utopia\Database\Helpers\Permission;
use Utopia\Database\Helpers\Role;
use Utopia\Validator;
use Utopia\Validator\Nullable;
class Swagger2 extends Format
{
@@ -285,6 +286,13 @@ class Swagger2 extends Format
}
}
$isNullable = $validator instanceof Nullable;
if ($isNullable) {
/** @var Nullable $validator */
$validator = $validator->getValidator();
}
switch ((!empty($validator)) ? \get_class($validator) : '') {
case 'Utopia\Validator\Text':
$node['type'] = $validator->getType();
@@ -448,6 +456,10 @@ class Swagger2 extends Format
$body['schema']['properties'][$name]['x-global'] = true;
}
if ($isNullable) {
$body['schema']['properties'][$name]['x-nullable'] = true;
}
if (\array_key_exists('items', $node)) {
$body['schema']['properties'][$name]['items'] = $node['items'];
}