From 629d09497f49ca32a88ab636992d77e7b3afdc8f Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sat, 19 Feb 2022 11:24:34 +0000 Subject: [PATCH 1/2] fix spec for resumable upload --- src/Appwrite/Specification/Format/OpenAPI3.php | 3 +++ src/Appwrite/Specification/Format/Swagger2.php | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index 5429211e8..cd9a0b28a 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -275,6 +275,9 @@ class OpenAPI3 extends Format $node['schema']['x-example'] = false; break; case 'Utopia\Database\Validator\UID': + $node['schema']['type'] = $validator->getType(); + $node['schema']['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']'; + break; case 'Appwrite\Utopia\Database\Validator\CustomId': if($route->getLabel('sdk.methodType', '') === 'upload') { $node['schema']['x-upload-id'] = true; diff --git a/src/Appwrite/Specification/Format/Swagger2.php b/src/Appwrite/Specification/Format/Swagger2.php index a2a09e14e..e24030ea7 100644 --- a/src/Appwrite/Specification/Format/Swagger2.php +++ b/src/Appwrite/Specification/Format/Swagger2.php @@ -262,7 +262,6 @@ class Swagger2 extends Format $node['type'] = $validator->getType(); $node['x-example'] = false; break; - case 'Utopia\Database\Validator\UID': case 'Appwrite\Utopia\Database\Validator\CustomId': if($route->getLabel('sdk.methodType', '') === 'upload') { $node['x-upload-id'] = true; @@ -270,6 +269,10 @@ class Swagger2 extends Format $node['type'] = $validator->getType(); $node['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']'; break; + case 'Utopia\Database\Validator\UID': + $node['type'] = $validator->getType(); + $node['x-example'] = '['.\strtoupper(Template::fromCamelCaseToSnake($node['name'])).']'; + break; case 'Appwrite\Network\Validator\Email': $node['type'] = $validator->getType(); $node['format'] = 'email'; From b71e9de578e59bcaa3de6275acc71bcc6895e0a4 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Sun, 20 Feb 2022 09:22:42 +0000 Subject: [PATCH 2/2] fix open api spec --- src/Appwrite/Specification/Format/OpenAPI3.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Appwrite/Specification/Format/OpenAPI3.php b/src/Appwrite/Specification/Format/OpenAPI3.php index cd9a0b28a..214b9d858 100644 --- a/src/Appwrite/Specification/Format/OpenAPI3.php +++ b/src/Appwrite/Specification/Format/OpenAPI3.php @@ -378,9 +378,13 @@ class OpenAPI3 extends Format $body['content'][$consumes[0]]['schema']['properties'][$name] = [ 'type' => $node['schema']['type'], 'description' => $node['description'], - 'x-example' => $node['x-example'] ?? null, + 'x-example' => $node['schema']['x-example'] ?? null ]; + if($node['schema']['x-upload-id'] ?? false) { + $body['content'][$consumes[0]]['schema']['properties'][$name]['x-upload-id'] = $node['schema']['x-upload-id']; + } + if(isset($node['default'])) { $body['content'][$consumes[0]]['schema']['properties'][$name]['default'] = $node['default']; }