From 0025d12a4f8e85f97542ef2bb906f237b0b78c3a Mon Sep 17 00:00:00 2001 From: eldadfux Date: Wed, 14 Aug 2019 14:52:40 +0300 Subject: [PATCH] Added conusme field to open api route --- app/app.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/app.php b/app/app.php index 0859c99008..a7ae90ea1a 100644 --- a/app/app.php +++ b/app/app.php @@ -533,7 +533,7 @@ $utopia->get('/v1/open-api-2.json') 'host' => $domain, 'basePath' => '/v1', 'schemes' => ['https'], - 'consumes' => ['application/json', 'application/x-www-form-urlencoded'], + 'consumes' => ['application/json', 'multipart/form-data'], 'produces' => ['application/json'], 'securityDefinitions' => [ 'Project' => [ @@ -632,9 +632,10 @@ $utopia->get('/v1/open-api-2.json') continue; } - $url = str_replace('/v1', '', $route->getURL()); - $scope = $route->getLabel('scope', ''); - $hide = $route->getLabel('sdk.hide', false); + $url = str_replace('/v1', '', $route->getURL()); + $scope = $route->getLabel('scope', ''); + $hide = $route->getLabel('sdk.hide', false); + $consumes = []; if($hide) { continue; @@ -643,6 +644,7 @@ $utopia->get('/v1/open-api-2.json') $temp = [ 'summary' => $route->getDesc(), 'operationId' => $route->getLabel('sdk.method', uniqid()), + 'consumes' => [], 'tags' => [$route->getLabel('sdk.namespace', 'default')], 'description' => $route->getLabel('sdk.description', ''), 'responses' => [ @@ -715,6 +717,7 @@ $utopia->get('/v1/open-api-2.json') //$node['format'] = 'json'; break; case 'Storage\Validators\File': + $consumes[] = ['multipart/form-data']; $node['type'] = 'file'; $temp['consumes'] = ['multipart/form-data']; break; @@ -781,6 +784,8 @@ $utopia->get('/v1/open-api-2.json') $url = str_replace(':' . $name, '{' . $name . '}', $url); } + $temp['consumes'] = $consumes; + $output['paths'][$url][strtolower($route->getMethod())] = $temp; } }