Merge pull request #2813 from appwrite/fix-swagger-resumable-upload

fix spec for resumable upload
This commit is contained in:
Eldad A. Fux
2022-02-20 16:20:02 +02:00
committed by GitHub
2 changed files with 12 additions and 2 deletions
@@ -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;
@@ -375,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'];
}
@@ -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';