@@ -52,10 +52,10 @@ discard block |
||
52 | 52 | if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) { |
53 | 53 | $modules = [ |
54 | 54 | 'name' => $module, |
55 | - 'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
55 | + 'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
56 | 56 | ]; |
57 | 57 | } |
58 | - } catch (\Exception $e) { |
|
58 | + }catch (\Exception $e) { |
|
59 | 59 | $modules[] = $e->getMessage(); |
60 | 60 | } |
61 | 61 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | */ |
74 | 74 | public function extractApiEndpoints(array $module) |
75 | 75 | { |
76 | - $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
76 | + $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
77 | 77 | $module_name = $module['name']; |
78 | 78 | $endpoints = []; |
79 | 79 | if (file_exists($module_path)) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | if (count($finder)) { |
83 | 83 | /** @var \SplFileInfo $file */ |
84 | 84 | foreach ($finder as $file) { |
85 | - $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
85 | + $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
86 | 86 | $info = $this->extractApiInfo($namespace, $module_name); |
87 | 87 | if (!empty($info)) { |
88 | 88 | $endpoints[$namespace] = $info; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | if (NULL !== $mInfo) { |
112 | 112 | $info[] = $mInfo; |
113 | 113 | } |
114 | - } catch (\Exception $e) { |
|
114 | + }catch (\Exception $e) { |
|
115 | 115 | Logger::getInstance()->errorLog($e->getMessage()); |
116 | 116 | } |
117 | 117 | } |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
325 | 325 | $payload = $this->extractDtoProperties($namespace); |
326 | 326 | } |
327 | - } catch (\Exception $e) { |
|
327 | + }catch (\Exception $e) { |
|
328 | 328 | Logger::getInstance()->errorLog($e->getMessage()); |
329 | 329 | } |
330 | 330 | |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | $return = $this->extractReturn($modelNamespace, $docComments); |
356 | 356 | $url = array_pop($route); |
357 | 357 | $methodInfo = [ |
358 | - 'url' => str_replace("/" . $module . "/api", '', $url), |
|
358 | + 'url' => str_replace("/".$module."/api", '', $url), |
|
359 | 359 | 'method' => $info['http'], |
360 | 360 | 'description' => $info['label'], |
361 | 361 | 'return' => $return, |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $this->setRequestParams($method, $methodInfo, $modelNamespace, $docComments); |
367 | 367 | $this->setQueryParams($method, $methodInfo); |
368 | 368 | $this->setRequestHeaders($reflection, $methodInfo); |
369 | - } catch (\Exception $e) { |
|
369 | + }catch (\Exception $e) { |
|
370 | 370 | jpre($e->getMessage()); |
371 | 371 | Logger::getInstance()->errorLog($e->getMessage()); |
372 | 372 | } |
@@ -516,10 +516,10 @@ discard block |
||
516 | 516 | $formatted = [ |
517 | 517 | "swagger" => "2.0", |
518 | 518 | "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)), |
519 | - "basePath" => '/' . $module['name'] . '/api', |
|
519 | + "basePath" => '/'.$module['name'].'/api', |
|
520 | 520 | "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"], |
521 | 521 | "info" => [ |
522 | - "title" => _('Documentación API módulo ') . $module['name'], |
|
522 | + "title" => _('Documentación API módulo ').$module['name'], |
|
523 | 523 | "version" => Config::getParam('api.version', '1.0'), |
524 | 524 | "contact" => [ |
525 | 525 | "name" => Config::getParam("author", "Fran López"), |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | foreach ($endpoints as $model) { |
533 | 533 | foreach ($model as $endpoint) { |
534 | 534 | if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
535 | - $url = preg_replace('/\/' . $module['name'] . '\/api/i', '', $endpoint['url']); |
|
535 | + $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); |
|
536 | 536 | $description = $endpoint['description']; |
537 | 537 | $method = strtolower($endpoint['method']); |
538 | 538 | $paths[$url][$method] = [ |
@@ -567,16 +567,16 @@ discard block |
||
567 | 567 | foreach ($endpoint['objects'] as $name => $object) { |
568 | 568 | if (class_exists($name)) { |
569 | 569 | $class = GeneratorHelper::extractClassFromNamespace($name); |
570 | - if(array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) { |
|
570 | + if (array_key_exists('data', $endpoint['return']) && count(array_keys($object)) === count(array_keys($endpoint['return']['data']))) { |
|
571 | 571 | $classDefinition = [ |
572 | 572 | 'type' => 'object', |
573 | - '$ref' => '#/definitions/' . $class, |
|
573 | + '$ref' => '#/definitions/'.$class, |
|
574 | 574 | ]; |
575 | - } else { |
|
575 | + }else { |
|
576 | 576 | $classDefinition = [ |
577 | 577 | 'type' => 'array', |
578 | 578 | 'items' => [ |
579 | - '$ref' => '#/definitions/' . $class, |
|
579 | + '$ref' => '#/definitions/'.$class, |
|
580 | 580 | ], |
581 | 581 | ]; |
582 | 582 | } |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | 'required' => true, |
591 | 591 | 'schema' => [ |
592 | 592 | 'type' => 'object', |
593 | - '$ref' => '#/definitions/' . $class, |
|
593 | + '$ref' => '#/definitions/'.$class, |
|
594 | 594 | ], |
595 | 595 | ]; |
596 | 596 | } |
@@ -617,7 +617,7 @@ discard block |
||
617 | 617 | protected function extractDtoName($dto, $isArray = false) |
618 | 618 | { |
619 | 619 | $dto = explode('\\', $dto); |
620 | - $modelDto = array_pop($dto) . "Dto"; |
|
620 | + $modelDto = array_pop($dto)."Dto"; |
|
621 | 621 | if ($isArray) { |
622 | 622 | $modelDto .= "List"; |
623 | 623 | } |
@@ -667,10 +667,10 @@ discard block |
||
667 | 667 | { |
668 | 668 | |
669 | 669 | $methodInfo['headers'] = []; |
670 | - foreach($reflection->getProperties() as $property) { |
|
670 | + foreach ($reflection->getProperties() as $property) { |
|
671 | 671 | $doc = $property->getDocComment(); |
672 | 672 | preg_match('/@header\ (.*)\n/i', $doc, $headers); |
673 | - if(count($headers)) { |
|
673 | + if (count($headers)) { |
|
674 | 674 | $header = [ |
675 | 675 | "name" => $headers[1], |
676 | 676 | "in" => "header", |
@@ -682,13 +682,13 @@ discard block |
||
682 | 682 | |
683 | 683 | // Extract description |
684 | 684 | preg_match('/@label\ (.*)\n/i', $doc, $label); |
685 | - if(count($label)) { |
|
685 | + if (count($label)) { |
|
686 | 686 | $header['description'] = _($label[1]); |
687 | 687 | } |
688 | 688 | |
689 | 689 | // Extract default value |
690 | 690 | preg_match('/@default\ (.*)\n/i', $doc, $default); |
691 | - if(count($default)) { |
|
691 | + if (count($default)) { |
|
692 | 692 | $header['default'] = $default[1]; |
693 | 693 | } |
694 | 694 | $methodInfo['headers'][] = $header; |
@@ -715,7 +715,7 @@ discard block |
||
715 | 715 | foreach ($method->getParameters() as $parameter) { |
716 | 716 | $parameterName = $parameter->getName(); |
717 | 717 | $types = []; |
718 | - preg_match_all('/\@param\ (.*)\ \$' . $parameterName . '$/im', $docComments, $types); |
|
718 | + preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); |
|
719 | 719 | if (count($types) > 1) { |
720 | 720 | $methodInfo['parameters'][$parameterName] = $types[1][0]; |
721 | 721 | } |