From 5dadd8caea0965e2cf1a4c464170963a7feeca41 Mon Sep 17 00:00:00 2001 From: Bradley Schofield Date: Fri, 24 Jan 2025 16:19:43 +0900 Subject: [PATCH] Fix required/whitelist system and descriptions --- app/config/specs/open-api3-latest-client.json | 28 +++++++++++++++++-- .../specs/open-api3-latest-console.json | 28 +++++++++++++++++-- app/config/specs/open-api3-latest-server.json | 28 +++++++++++++++++-- app/config/specs/swagger2-latest-client.json | 27 ++++++++++++++++-- app/config/specs/swagger2-latest-console.json | 27 ++++++++++++++++-- app/config/specs/swagger2-latest-server.json | 27 ++++++++++++++++-- .../Specification/Format/OpenAPI3.php | 12 ++++---- .../Specification/Format/Swagger2.php | 12 ++++---- 8 files changed, 165 insertions(+), 24 deletions(-) diff --git a/app/config/specs/open-api3-latest-client.json b/app/config/specs/open-api3-latest-client.json index 55b7f590ab..4a93fa40d8 100644 --- a/app/config/specs/open-api3-latest-client.json +++ b/app/config/specs/open-api3-latest-client.json @@ -4396,7 +4396,30 @@ "server" ], "packaging": false, - "additional-methods": [ + "methods": [ + { + "name": "createDocument", + "parameters": [ + "databaseId", + "collectionId", + "documentId", + "data", + "permissions" + ], + "required": [ + "databaseId", + "collectionId", + "documentId", + "data" + ], + "responses": [ + { + "code": 201, + "model": "#\/components\/schemas\/document" + } + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." + }, { "name": "createDocuments", "parameters": [ @@ -4414,7 +4437,8 @@ "code": 201, "model": "#\/components\/schemas\/documentList" } - ] + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." } ], "auth": { diff --git a/app/config/specs/open-api3-latest-console.json b/app/config/specs/open-api3-latest-console.json index 80e7b4aa48..5b26aaabc2 100644 --- a/app/config/specs/open-api3-latest-console.json +++ b/app/config/specs/open-api3-latest-console.json @@ -7854,7 +7854,30 @@ "server" ], "packaging": false, - "additional-methods": [ + "methods": [ + { + "name": "createDocument", + "parameters": [ + "databaseId", + "collectionId", + "documentId", + "data", + "permissions" + ], + "required": [ + "databaseId", + "collectionId", + "documentId", + "data" + ], + "responses": [ + { + "code": 201, + "model": "#\/components\/schemas\/document" + } + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." + }, { "name": "createDocuments", "parameters": [ @@ -7872,7 +7895,8 @@ "code": 201, "model": "#\/components\/schemas\/documentList" } - ] + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." } ], "auth": { diff --git a/app/config/specs/open-api3-latest-server.json b/app/config/specs/open-api3-latest-server.json index a2ba79a6b9..5af2594a0e 100644 --- a/app/config/specs/open-api3-latest-server.json +++ b/app/config/specs/open-api3-latest-server.json @@ -7412,7 +7412,30 @@ "server" ], "packaging": false, - "additional-methods": [ + "methods": [ + { + "name": "createDocument", + "parameters": [ + "databaseId", + "collectionId", + "documentId", + "data", + "permissions" + ], + "required": [ + "databaseId", + "collectionId", + "documentId", + "data" + ], + "responses": [ + { + "code": 201, + "model": "#\/components\/schemas\/document" + } + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." + }, { "name": "createDocuments", "parameters": [ @@ -7430,7 +7453,8 @@ "code": 201, "model": "#\/components\/schemas\/documentList" } - ] + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." } ], "auth": { diff --git a/app/config/specs/swagger2-latest-client.json b/app/config/specs/swagger2-latest-client.json index 564b2953a1..42fa5e9a61 100644 --- a/app/config/specs/swagger2-latest-client.json +++ b/app/config/specs/swagger2-latest-client.json @@ -4574,7 +4574,30 @@ "server" ], "packaging": false, - "additional-methods": [ + "methods": [ + { + "name": "createDocument", + "parameters": [ + "databaseId", + "collectionId", + "documentId", + "data", + "permissions" + ], + "required": [ + "databaseId", + "collectionId", + "documentId", + "data" + ], + "responses": [ + { + "code": 201, + "model": "#\/definitions\/document" + } + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." + }, { "name": "createDocuments", "parameters": [ @@ -4593,7 +4616,7 @@ "model": "#\/definitions\/documentList" } ], - "description": "\/docs\/references\/databases\/create-document.md" + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." } ], "auth": { diff --git a/app/config/specs/swagger2-latest-console.json b/app/config/specs/swagger2-latest-console.json index 9bd031b562..de0118aca8 100644 --- a/app/config/specs/swagger2-latest-console.json +++ b/app/config/specs/swagger2-latest-console.json @@ -8039,7 +8039,30 @@ "server" ], "packaging": false, - "additional-methods": [ + "methods": [ + { + "name": "createDocument", + "parameters": [ + "databaseId", + "collectionId", + "documentId", + "data", + "permissions" + ], + "required": [ + "databaseId", + "collectionId", + "documentId", + "data" + ], + "responses": [ + { + "code": 201, + "model": "#\/definitions\/document" + } + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." + }, { "name": "createDocuments", "parameters": [ @@ -8058,7 +8081,7 @@ "model": "#\/definitions\/documentList" } ], - "description": "\/docs\/references\/databases\/create-document.md" + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." } ], "auth": { diff --git a/app/config/specs/swagger2-latest-server.json b/app/config/specs/swagger2-latest-server.json index b29b790160..a787aa26d2 100644 --- a/app/config/specs/swagger2-latest-server.json +++ b/app/config/specs/swagger2-latest-server.json @@ -7579,7 +7579,30 @@ "server" ], "packaging": false, - "additional-methods": [ + "methods": [ + { + "name": "createDocument", + "parameters": [ + "databaseId", + "collectionId", + "documentId", + "data", + "permissions" + ], + "required": [ + "databaseId", + "collectionId", + "documentId", + "data" + ], + "responses": [ + { + "code": 201, + "model": "#\/definitions\/document" + } + ], + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." + }, { "name": "createDocuments", "parameters": [ @@ -7598,7 +7621,7 @@ "model": "#\/definitions\/documentList" } ], - "description": "\/docs\/references\/databases\/create-document.md" + "description": "Create new Documents. Before using this route, you should create a new collection resource using either a [server integration](https:\/\/appwrite.io\/docs\/server\/databases#databasesCreateCollection) API or directly from your database console." } ], "auth": { diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index bd5405539d..847dfd8eff 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -131,10 +131,8 @@ class OpenAPI3 extends Format $additionalMethods = null; if (is_array($sdk)) { - $mainSdk = array_shift($sdk); $additionalMethods = $sdk; - - $sdk = $mainSdk; + $sdk = $sdk[0]; } /** @@ -202,14 +200,16 @@ class OpenAPI3 extends Format if (!empty($additionalMethods)) { - $temp['x-appwrite']['additional-methods'] = []; + $temp['x-appwrite']['methods'] = []; foreach ($additionalMethods as $method) { /** @var \Appwrite\SDK\Method $method */ + $desc = $method->getDescriptionFilePath(); $additionalMethod = [ 'name' => $method->getMethodName(), 'parameters' => [], 'required' => [], - 'responses' => [] + 'responses' => [], + 'description' => ($desc) ? \file_get_contents($desc) : '', ]; foreach ($method->getParameters() as $name => $param) { @@ -228,7 +228,7 @@ class OpenAPI3 extends Format ]; } - $temp['x-appwrite']['additional-methods'][] = $additionalMethod; + $temp['x-appwrite']['methods'][] = $additionalMethod; } } diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index 7277e3ab2b..c3f37cb33a 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -130,10 +130,8 @@ class Swagger2 extends Format $additionalMethods = null; if (is_array($sdk)) { - $mainSdk = array_shift($sdk); $additionalMethods = $sdk; - - $sdk = $mainSdk; + $sdk = $sdk[0]; } $consumes = [$sdk->getRequestType()]; @@ -203,15 +201,17 @@ class Swagger2 extends Format } if (!empty($additionalMethods)) { - $temp['x-appwrite']['additional-methods'] = []; + $temp['x-appwrite']['methods'] = []; foreach ($additionalMethods as $method) { /** @var \Appwrite\SDK\Method $method */ + $desc = $method->getDescriptionFilePath(); + $additionalMethod = [ 'name' => $method->getMethodName(), 'parameters' => [], 'required' => [], 'responses' => [], - 'description' => $method->getDescription(), + 'description' => ($desc) ? \file_get_contents($desc) : '', ]; foreach ($method->getParameters() as $name => $param) { @@ -230,7 +230,7 @@ class Swagger2 extends Format ]; } - $temp['x-appwrite']['additional-methods'][] = $additionalMethod; + $temp['x-appwrite']['methods'][] = $additionalMethod; } }