Completed
Pull Request — master (#158)
by
unknown
10:40
created
src/Handlers/OpenApiHandler.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
         $data = [
159 159
             'openapi' => '3.0.0',
160 160
             'info' => [
161
-                'version' => (string)$version,
161
+                'version' => (string) $version,
162 162
                 'title' => 'Nette API',
163 163
             ],
164 164
             'servers' => [
@@ -217,11 +217,11 @@  discard block
 block discarded – undo
217 217
             'paths' => $this->getPaths($apis, $baseUrl, $basePath),
218 218
         ];
219 219
 
220
-        if (!$securitySchemes) {
220
+        if ( ! $securitySchemes) {
221 221
             unset($data['components']['securitySchemes']);
222 222
         }
223 223
 
224
-        if (!empty($this->definitions)) {
224
+        if ( ! empty($this->definitions)) {
225 225
             $data['components']['schemas'] = array_merge($this->definitions, $data['components']['schemas']);
226 226
         }
227 227
 
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
     private function getApis(string $version): array
237 237
     {
238
-        return array_filter($this->apiDecider->getApis(), function (Api $api) use ($version) {
238
+        return array_filter($this->apiDecider->getApis(), function(Api $api) use ($version) {
239 239
             return $version === $api->getEndpoint()->getVersion();
240 240
         });
241 241
     }
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
             $path = str_replace([$baseUrl, $basePath], '', $this->apiLink->link($api->getEndpoint()));
256 256
             $responses = [];
257 257
             $endpointPath = str_replace('v' . $api->getEndpoint()->getVersion() . '/', '', $api->getEndpoint()->getUrl());
258
-            if (!$this->isPathAllowed($endpointPath, $api->getEndpoint()->getMethod())) {
258
+            if ( ! $this->isPathAllowed($endpointPath, $api->getEndpoint()->getMethod())) {
259 259
                 continue;
260 260
             }
261 261
 
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             $parameters = $this->createParamsList($handler);
273 273
             $requestBody = $this->createRequestBody($handler);
274 274
 
275
-            if (!empty($parameters) || !empty($requestBody)) {
275
+            if ( ! empty($parameters) || ! empty($requestBody)) {
276 276
                 $responses[IResponse::S400_BAD_REQUEST] = [
277 277
                     'description' => 'Bad request',
278 278
                     'content' => [
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
 
288 288
             $authorization = $api->getAuthorization();
289 289
 
290
-            if (!$authorization instanceof NoAuthorization) {
290
+            if ( ! $authorization instanceof NoAuthorization) {
291 291
                 $responses[IResponse::S403_FORBIDDEN] = [
292 292
                     'description' => 'Operation forbidden',
293 293
                     'content' => [
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
             foreach ($handler->outputs() as $output) {
315 315
                 if ($output instanceof JsonOutput) {
316 316
                     $schema = $this->transformSchema(json_decode($output->getSchema(), true));
317
-                    if (!isset($responses[$output->getCode()])) {
317
+                    if ( ! isset($responses[$output->getCode()])) {
318 318
                         $responses[$output->getCode()] = [
319 319
                             'description' => $output->getDescription(),
320 320
                             'content' => [
@@ -323,7 +323,7 @@  discard block
 block discarded – undo
323 323
                                 ],
324 324
                             ],
325 325
                         ];
326
-                        if (!empty($examples = $output->getExamples())) {
326
+                        if ( ! empty($examples = $output->getExamples())) {
327 327
                             if (count($examples) === 1) {
328 328
                                 $example = is_array($output->getExample()) ? $output->getExample() : json_decode($output->getExample(), true);
329 329
                                 $responses[$output->getCode()]['content']['application/json; charset=utf-8']['example'] = $example;
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
                             }
336 336
                         }
337 337
                     } else {
338
-                        if (!isset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']['oneOf'])) {
338
+                        if ( ! isset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']['oneOf'])) {
339 339
                             $tmp = $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema'];
340 340
                             unset($responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema']);
341 341
                             $responses[$output->getCode()]['content']['application/json; charset=utf-8']['schema'] = [
@@ -362,11 +362,11 @@  discard block
 block discarded – undo
362 362
                 }
363 363
             }
364 364
 
365
-            if (!empty($parameters)) {
365
+            if ( ! empty($parameters)) {
366 366
                 $settings['parameters'] = $parameters;
367 367
             }
368 368
 
369
-            if (!empty($requestBody)) {
369
+            if ( ! empty($requestBody)) {
370 370
                 $settings['requestBody'] = $requestBody;
371 371
             }
372 372
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
         foreach ($handler->params() as $param) {
531 531
             if ($param instanceof JsonInputParam) {
532 532
                 $schema = json_decode($param->getSchema(), true);
533
-                if (!empty($examples = $param->getExamples())) {
533
+                if ( ! empty($examples = $param->getExamples())) {
534 534
                     if (count($examples) === 1) {
535 535
                         $schema['example'] = is_array($param->getExample()) ? $param->getExample() : json_decode($param->getExample(), true);
536 536
                     } else {
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
                 $schema = [
554 554
                     'type' => 'string',
555 555
                 ];
556
-                if (!empty($examples = $param->getExamples())) {
556
+                if ( ! empty($examples = $param->getExamples())) {
557 557
                     if (count($examples) === 1) {
558 558
                         $schema['example'] = $param->getExample();
559 559
                     } else {
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
             }
623 623
         }
624 624
 
625
-        if (!empty($requestBody['properties'])) {
625
+        if ( ! empty($requestBody['properties'])) {
626 626
             $requestBodySchema = [
627 627
                 'type' => 'object',
628 628
                 'properties' => $requestBody['properties'],
Please login to merge, or discard this patch.