From eb1476b28b12f5f7d25b326c849a9946bc8a7c5d Mon Sep 17 00:00:00 2001 From: Jake Barnby Date: Mon, 22 Aug 2022 14:27:17 +1200 Subject: [PATCH] Apply validator updates to OpenAPI3 --- app/controllers/api/databases.php | 1 - src/Appwrite/Specification/Format/OpenAPI3.php | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/api/databases.php b/app/controllers/api/databases.php index f1f3356ff1..1ddd9d5b7f 100644 --- a/app/controllers/api/databases.php +++ b/app/controllers/api/databases.php @@ -1927,7 +1927,6 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents') } } - // Users can only manage their own roles, API keys and Admin users can manage any // Users can only manage their own roles, API keys and Admin users can manage any $roles = Authorization::getRoles(); if (!Auth::isAppUser($roles) && !Auth::isPrivilegedUser($roles)) { diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index a9ac79e0c8..c7a9db0524 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -5,6 +5,8 @@ namespace Appwrite\Specification\Format; use Appwrite\Specification\Format; use Appwrite\Template\Template; use Appwrite\Utopia\Response\Model; +use Utopia\Database\Permission; +use Utopia\Database\Role; use Utopia\Validator; class OpenAPI3 extends Format @@ -338,6 +340,14 @@ class OpenAPI3 extends Format $node['schema']['items'] = [ 'type' => 'string', ]; + $node['schema']['x-example'] = '["' . Permission::read(Role::any()) . '"]'; + break; + case 'Utopia\Database\Validator\Roles': + $node['schema']['type'] = $validator->getType(); + $node['schema']['items'] = [ + 'type' => 'string', + ]; + $node['schema']['x-example'] = '["' . Role::any()->toString() . '"]'; break; case 'Appwrite\Auth\Validator\Password': $node['schema']['type'] = $validator->getType();