@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | if (!preg_match('/^ROOT/i', $module) && $module == $requestModule) { |
42 | 42 | $modules = [ |
43 | 43 | 'name' => $module, |
44 | - 'path' => realpath($info['template'] . DIRECTORY_SEPARATOR . '..'), |
|
44 | + 'path' => realpath($info['template'].DIRECTORY_SEPARATOR.'..'), |
|
45 | 45 | ]; |
46 | 46 | } |
47 | - } catch (\Exception $e) { |
|
47 | + }catch (\Exception $e) { |
|
48 | 48 | $modules[] = $e->getMessage(); |
49 | 49 | } |
50 | 50 | } |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function extractApiEndpoints(array $module) |
64 | 64 | { |
65 | - $module_path = $module['path'] . DIRECTORY_SEPARATOR . 'Api'; |
|
65 | + $module_path = $module['path'].DIRECTORY_SEPARATOR.'Api'; |
|
66 | 66 | $module_name = $module['name']; |
67 | 67 | $endpoints = []; |
68 | 68 | if (file_exists($module_path)) { |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | if (count($finder)) { |
72 | 72 | /** @var \SplFileInfo $file */ |
73 | 73 | foreach ($finder as $file) { |
74 | - $namespace = "\\{$module_name}\\Api\\" . str_replace('.php', '', $file->getFilename()); |
|
74 | + $namespace = "\\{$module_name}\\Api\\".str_replace('.php', '', $file->getFilename()); |
|
75 | 75 | $info = $this->extractApiInfo($namespace, $module_name); |
76 | 76 | if (!empty($info)) { |
77 | 77 | $endpoints[$namespace] = $info; |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | if (NULL !== $mInfo) { |
101 | 101 | $info[] = $mInfo; |
102 | 102 | } |
103 | - } catch (\Exception $e) { |
|
103 | + }catch (\Exception $e) { |
|
104 | 104 | Logger::getInstance()->errorLog($e->getMessage()); |
105 | 105 | } |
106 | 106 | } |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | } elseif (null !== $reflector && $reflector->isSubclassOf(self::DTO_INTERFACE)) { |
313 | 313 | $payload = $this->extractDtoProperties($namespace); |
314 | 314 | } |
315 | - } catch (\Exception $e) { |
|
315 | + }catch (\Exception $e) { |
|
316 | 316 | Logger::getInstance()->errorLog($e->getMessage()); |
317 | 317 | } |
318 | 318 | |
@@ -351,18 +351,18 @@ discard block |
||
351 | 351 | unset($methodInfo['return']['objects']); |
352 | 352 | if (in_array($methodInfo['method'], ['POST', 'PUT'])) { |
353 | 353 | $methodInfo['payload'] = $this->extractPayload($modelNamespace, $docComments); |
354 | - } elseif($method->getNumberOfParameters() > 0) { |
|
354 | + } elseif ($method->getNumberOfParameters() > 0) { |
|
355 | 355 | $methodInfo['parameters'] = []; |
356 | - foreach($method->getParameters() as $parameter) { |
|
356 | + foreach ($method->getParameters() as $parameter) { |
|
357 | 357 | $parameterName = $parameter->getName(); |
358 | 358 | $types = []; |
359 | 359 | preg_match_all('/\@param\ (.*)\ \$'.$parameterName.'$/im', $docComments, $types); |
360 | - if(count($types) > 1) { |
|
360 | + if (count($types) > 1) { |
|
361 | 361 | $methodInfo['parameters'][$parameterName] = $types[1][0]; |
362 | 362 | } |
363 | 363 | } |
364 | 364 | } |
365 | - } catch (\Exception $e) { |
|
365 | + }catch (\Exception $e) { |
|
366 | 366 | jpre($e->getMessage()); |
367 | 367 | Logger::getInstance()->errorLog($e->getMessage()); |
368 | 368 | } |
@@ -444,13 +444,13 @@ discard block |
||
444 | 444 | ]]); |
445 | 445 | if (array_key_exists($subDtoName, $subDto)) { |
446 | 446 | $definitions = $subDto; |
447 | - } else { |
|
447 | + }else { |
|
448 | 448 | $definitions[$subDtoName] = $subDto; |
449 | 449 | } |
450 | 450 | $definition[$name]['properties'][$field] = [ |
451 | - '$ref' => "#/definitions/" . $subDtoName, |
|
451 | + '$ref' => "#/definitions/".$subDtoName, |
|
452 | 452 | ]; |
453 | - } else { |
|
453 | + }else { |
|
454 | 454 | list($type, $format) = self::translateSwaggerFormats($format); |
455 | 455 | $dto['properties'][$field] = [ |
456 | 456 | "type" => $type, |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | private static function swaggerResponses() { |
473 | 473 | $codes = [200, 400, 404, 500]; |
474 | 474 | $responses = []; |
475 | - foreach($codes as $code) { |
|
476 | - switch($code) { |
|
475 | + foreach ($codes as $code) { |
|
476 | + switch ($code) { |
|
477 | 477 | default: |
478 | 478 | case 200: |
479 | 479 | $message = _('Successful response'); |
@@ -525,10 +525,10 @@ discard block |
||
525 | 525 | $formatted = [ |
526 | 526 | "swagger" => "2.0", |
527 | 527 | "host" => preg_replace('/^(http|https)\:\/\/(.*)\/$/i', '$2', Router::getInstance()->getRoute('', true)), |
528 | - "basePath" => '/' . $module['name'] . '/api', |
|
529 | - "schemes" => ["http","https"], |
|
528 | + "basePath" => '/'.$module['name'].'/api', |
|
529 | + "schemes" => ["http", "https"], |
|
530 | 530 | "info" => [ |
531 | - "title" => _('Documentación API módulo ') . $module['name'], |
|
531 | + "title" => _('Documentación API módulo ').$module['name'], |
|
532 | 532 | "version" => Config::getParam('api.version', '1.0'), |
533 | 533 | "contact" => [ |
534 | 534 | "name" => Config::getParam("author", "Fran López"), |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | $endpoints = DocumentorService::getInstance()->extractApiEndpoints($module); |
541 | 541 | foreach ($endpoints as $model) { |
542 | 542 | foreach ($model as $endpoint) { |
543 | - if(!preg_match('/^\/admin\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
|
543 | + if (!preg_match('/^\/admin\//i', $endpoint['url']) && strlen($endpoint['url'])) { |
|
544 | 544 | $url = preg_replace('/\/'.$module['name'].'\/api/i', '', $endpoint['url']); |
545 | 545 | $description = $endpoint['description']; |
546 | 546 | $method = strtolower($endpoint['method']); |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | 'responses' => self::swaggerResponses(), |
552 | 552 | 'parameters' => [], |
553 | 553 | ]; |
554 | - if(array_key_exists('parameters', $endpoint)) { |
|
555 | - foreach($endpoint['parameters'] as $parameter => $type) { |
|
554 | + if (array_key_exists('parameters', $endpoint)) { |
|
555 | + foreach ($endpoint['parameters'] as $parameter => $type) { |
|
556 | 556 | list($type, $format) = self::translateSwaggerFormats($type); |
557 | 557 | $paths[$url][$method]['parameters'][] = [ |
558 | 558 | 'in' => 'path', |
@@ -564,19 +564,19 @@ discard block |
||
564 | 564 | } |
565 | 565 | |
566 | 566 | } |
567 | - foreach($endpoint['objects'] as $name => $object) { |
|
568 | - if(class_exists($name)) { |
|
567 | + foreach ($endpoint['objects'] as $name => $object) { |
|
568 | + if (class_exists($name)) { |
|
569 | 569 | $class = GeneratorHelper::extractClassFromNamespace($name); |
570 | 570 | $classDefinition = [ |
571 | 571 | 'type' => 'object', |
572 | - '$ref' => '#/definitions/' . $class, |
|
572 | + '$ref' => '#/definitions/'.$class, |
|
573 | 573 | ]; |
574 | 574 | $paths[$url][$method]['responses'][200]['schema']['properties']['data'] = $classDefinition; |
575 | 575 | $dtos += self::extractSwaggerDefinition($class, $object); |
576 | - if(!isset($paths[$url][$method]['tags']) || !in_array($class, $paths[$url][$method]['tags'])) { |
|
576 | + if (!isset($paths[$url][$method]['tags']) || !in_array($class, $paths[$url][$method]['tags'])) { |
|
577 | 577 | $paths[$url][$method]['tags'][] = $class; |
578 | 578 | } |
579 | - if(array_key_exists('payload', $endpoint)) { |
|
579 | + if (array_key_exists('payload', $endpoint)) { |
|
580 | 580 | $paths[$url][$method]['parameters'][] = [ |
581 | 581 | 'in' => 'body', |
582 | 582 | 'name' => $class, |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | protected function extractDtoName($dto, $isArray = false) |
605 | 605 | { |
606 | 606 | $dto = explode('\\', $dto); |
607 | - $modelDto = array_pop($dto) . "Dto"; |
|
607 | + $modelDto = array_pop($dto)."Dto"; |
|
608 | 608 | if ($isArray) { |
609 | 609 | $modelDto .= "List"; |
610 | 610 | } |