From d1502bc7d64bd6cafd6fc5350c0f3cdb944a34df Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Thu, 6 Feb 2025 11:08:58 +0000 Subject: [PATCH] chore: update descriptions for token endpoints --- .../Storage/Http/Tokens/Buckets/Files/Create.php | 4 +++- .../Storage/Http/Tokens/Buckets/Files/XList.php | 4 +++- .../Platform/Modules/Storage/Http/Tokens/Delete.php | 4 +++- .../Platform/Modules/Storage/Http/Tokens/Get.php | 4 +++- .../Platform/Modules/Storage/Http/Tokens/JWT/Get.php | 4 +++- .../Platform/Modules/Storage/Http/Tokens/Update.php | 4 +++- src/Appwrite/SDK/Method.php | 10 ++++++---- src/Appwrite/Specification/Format/OpenAPI3.php | 5 ++++- src/Appwrite/Specification/Format/Swagger2.php | 5 ++++- 9 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/Create.php b/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/Create.php index 847a1d32b1..bf2b198890 100644 --- a/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/Create.php +++ b/src/Appwrite/Platform/Modules/Storage/Http/Tokens/Buckets/Files/Create.php @@ -47,7 +47,9 @@ class Create extends Action ->label('sdk', new Method( namespace: 'tokens', name: 'createFileToken', - description: '', + description: <<label('sdk', new Method( namespace: 'tokens', name: 'list', - description: '', + description: <<label('sdk', new Method( namespace: 'tokens', name: 'delete', - description: '', + description: <<label('sdk', new Method( namespace: 'tokens', name: 'get', - description: '', + description: <<label('sdk', new Method( namespace: 'tokens', name: 'getJWT', - description: '', + description: <<label('sdk', new Method( namespace: 'tokens', name: 'update', - description: '', + description: <<getDescriptionFilePath(); + if (\str_ends_with($desc, '.md')) { + $descPath = $this->getDescriptionFilePath(); - if (empty($descPath)) { - self::$errors[] = "Error with {$this->getRouteName()} method: Description file not found at {$desc}"; - return; + if (empty($descPath)) { + self::$errors[] = "Error with {$this->getRouteName()} method: Description file not found at {$desc}"; + return; + } } } diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index bd5405539d..e60d342b0b 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -177,11 +177,14 @@ class OpenAPI3 extends Format $namespace = $sdk->getNamespace() ?? 'default'; + $desc = $desc ?? ''; + $descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc; + $temp = [ 'summary' => $route->getDesc(), 'operationId' => $namespace . ucfirst($method), 'tags' => [$namespace], - 'description' => ($desc) ? \file_get_contents($desc) : '', + 'description' => $descContents, 'responses' => [], 'x-appwrite' => [ // Appwrite related metadata 'method' => $method, diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index 7277e3ab2b..fae164f0a6 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -173,13 +173,16 @@ class Swagger2 extends Format $namespace = $sdk->getNamespace() ?? 'default'; + $desc = $desc ?? ''; + $descContents = \str_ends_with($desc, '.md') ? \file_get_contents($desc) : $desc; + $temp = [ 'summary' => $route->getDesc(), 'operationId' => $namespace . ucfirst($method), 'consumes' => [], 'produces' => [], 'tags' => [$namespace], - 'description' => ($desc) ? \file_get_contents($desc) : '', + 'description' => $descContents, 'responses' => [], 'x-appwrite' => [ // Appwrite related metadata 'method' => $method,