@@ -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,13 +366,13 @@ discard block |
||
366 | 366 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
367 | 367 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
368 | 368 | } |
369 | - if($method->getNumberOfParameters() > 0) { |
|
369 | + if ($method->getNumberOfParameters() > 0) { |
|
370 | 370 | $methodInfo['parameters'] = []; |
371 | - foreach($method->getParameters() as $parameter) { |
|
371 | + foreach ($method->getParameters() as $parameter) { |
|
372 | 372 | $parameterName = $parameter->getName(); |
373 | 373 | $types = []; |
374 | 374 | preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); |
375 | - if(count($types) > 1) { |
|
375 | + if (count($types) > 1) { |
|
376 | 376 | $methodInfo['parameters'][$parameterName] = $types[1][0]; |
377 | 377 | } |
378 | 378 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | ] |
405 | 405 | ]; |
406 | 406 | } |
407 | - } catch (\Exception $e) { |
|
407 | + }catch (\Exception $e) { |
|
408 | 408 | jpre($e->getMessage()); |
409 | 409 | Logger::getInstance()->errorLog($e->getMessage()); |
410 | 410 | } |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | private static function swaggerResponses() { |
501 | 501 | $codes = [200, 400, 404, 500]; |
502 | 502 | $responses = []; |
503 | - foreach($codes as $code) { |
|
504 | - switch($code) { |
|
503 | + foreach ($codes as $code) { |
|
504 | + switch ($code) { |
|
505 | 505 | default: |
506 | 506 | case 200: |
507 | 507 | $message = _('Successful response'); |
@@ -553,10 +553,10 @@ discard block |
||
553 | 553 | $formatted = [ |
554 | 554 | "swagger" => "2.0", |
555 | 555 | "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)), |
556 | - "basePath" => '/' . $module['name'] . '/api', |
|
556 | + "basePath" => '/'.$module['name'].'/api', |
|
557 | 557 | "schemes" => [Request::getInstance()->getServer('HTTPS') == 'on' ? "https" : "http"], |
558 | 558 | "info" => [ |
559 | - "title" => _('Documentación API módulo ') . $module['name'], |
|
559 | + "title" => _('Documentación API módulo ').$module['name'], |
|
560 | 560 | "version" => Config::getParam('api.version', '1.0'), |
561 | 561 | "contact" => [ |
562 | 562 | "name" => Config::getParam("author", "Fran López"), |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | $endpoints = DocumentorService::getInstance()->extractApiEndpoints($module); |
569 | 569 | foreach ($endpoints as $model) { |
570 | 570 | foreach ($model as $endpoint) { |
571 | - if(!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
|
571 | + if (!preg_match('/^\/(admin|api)\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
|
572 | 572 | $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); |
573 | 573 | $description = $endpoint['description']; |
574 | 574 | $method = strtolower($endpoint['method']); |
@@ -579,8 +579,8 @@ discard block |
||
579 | 579 | 'responses' => self::swaggerResponses(), |
580 | 580 | 'parameters' => [], |
581 | 581 | ]; |
582 | - if(array_key_exists('parameters', $endpoint)) { |
|
583 | - foreach($endpoint['parameters'] as $parameter => $type) { |
|
582 | + if (array_key_exists('parameters', $endpoint)) { |
|
583 | + foreach ($endpoint['parameters'] as $parameter => $type) { |
|
584 | 584 | list($type, $format) = self::translateSwaggerFormats($type); |
585 | 585 | $paths[$url][$method]['parameters'][] = [ |
586 | 586 | 'in' => 'path', |
@@ -591,24 +591,24 @@ discard block |
||
591 | 591 | ]; |
592 | 592 | } |
593 | 593 | } |
594 | - if(array_key_exists('query', $endpoint)) { |
|
595 | - foreach($endpoint['query'] as $query) { |
|
594 | + if (array_key_exists('query', $endpoint)) { |
|
595 | + foreach ($endpoint['query'] as $query) { |
|
596 | 596 | $paths[$url][$method]['parameters'][] = $query; |
597 | 597 | } |
598 | 598 | } |
599 | - foreach($endpoint['objects'] as $name => $object) { |
|
600 | - if(class_exists($name)) { |
|
599 | + foreach ($endpoint['objects'] as $name => $object) { |
|
600 | + if (class_exists($name)) { |
|
601 | 601 | $class = GeneratorHelper::extractClassFromNamespace($name); |
602 | 602 | $classDefinition = [ |
603 | 603 | 'type' => 'object', |
604 | - '$ref' => '#/definitions/' . $class, |
|
604 | + '$ref' => '#/definitions/'.$class, |
|
605 | 605 | ]; |
606 | 606 | $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition; |
607 | 607 | $dtos += self::extractSwaggerDefinition($class, $object); |
608 | - if(!isset($paths[$url][$method]['tags']) || !in_array($class, $paths[$url][$method]['tags'])) { |
|
608 | + if (!isset($paths[$url][$method]['tags']) || !in_array($class, $paths[$url][$method]['tags'])) { |
|
609 | 609 | $paths[$url][$method]['tags'][] = $class; |
610 | 610 | } |
611 | - if(array_key_exists('payload', $endpoint)) { |
|
611 | + if (array_key_exists('payload', $endpoint)) { |
|
612 | 612 | $paths[$url][$method]['parameters'][] = [ |
613 | 613 | 'in' => 'body', |
614 | 614 | 'name' => $class, |
@@ -616,8 +616,8 @@ discard block |
||
616 | 616 | 'schema' => $classDefinition |
617 | 617 | ]; |
618 | 618 | } |
619 | - } else { |
|
620 | - if(!isset($paths[$url][$method]['tags']) || !in_array($endpoint['class'], $paths[$url][$method]['tags'])) { |
|
619 | + }else { |
|
620 | + if (!isset($paths[$url][$method]['tags']) || !in_array($endpoint['class'], $paths[$url][$method]['tags'])) { |
|
621 | 621 | $paths[$url][$method]['tags'][] = $endpoint['class']; |
622 | 622 | } |
623 | 623 | } |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | protected function extractDtoName($dto, $isArray = false) |
641 | 641 | { |
642 | 642 | $dto = explode('\\', $dto); |
643 | - $modelDto = array_pop($dto) . "Dto"; |
|
643 | + $modelDto = array_pop($dto)."Dto"; |
|
644 | 644 | if ($isArray) { |
645 | 645 | $modelDto .= "List"; |
646 | 646 | } |