@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $content = ResponseResolver::getResponse($route, $docBlock['tags'], $rulesToApply); |
| 61 | 61 | |
| 62 | 62 | $parsedRoute = [ |
| 63 | - 'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))), |
|
| 63 | + 'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))), |
|
| 64 | 64 | 'group' => $routeGroup, |
| 65 | 65 | 'title' => $docBlock['short'], |
| 66 | 66 | 'description' => $docBlock['long'], |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | 'parameters' => $this->getParametersFromDocBlock($docBlock['tags']), |
| 70 | 70 | 'authenticated' => $this->getAuthStatusFromDocBlock($docBlock['tags']), |
| 71 | 71 | 'response' => $content, |
| 72 | - 'showresponse' => ! empty($content), |
|
| 72 | + 'showresponse' => !empty($content), |
|
| 73 | 73 | ]; |
| 74 | 74 | $parsedRoute['headers'] = $rulesToApply['headers'] ?? []; |
| 75 | 75 | |
@@ -93,10 +93,10 @@ discard block |
||
| 93 | 93 | protected function getParametersFromDocBlock(array $tags) |
| 94 | 94 | { |
| 95 | 95 | $parameters = collect($tags) |
| 96 | - ->filter(function ($tag) { |
|
| 96 | + ->filter(function($tag) { |
|
| 97 | 97 | return $tag instanceof Tag && $tag->getName() === 'bodyParam'; |
| 98 | 98 | }) |
| 99 | - ->mapWithKeys(function ($tag) { |
|
| 99 | + ->mapWithKeys(function($tag) { |
|
| 100 | 100 | preg_match('/(.+?)\s+(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content); |
| 101 | 101 | if (empty($content)) { |
| 102 | 102 | // this means only name and type were supplied |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | protected function getAuthStatusFromDocBlock(array $tags) |
| 131 | 131 | { |
| 132 | 132 | $authTag = collect($tags) |
| 133 | - ->first(function ($tag) { |
|
| 133 | + ->first(function($tag) { |
|
| 134 | 134 | return $tag instanceof Tag && strtolower($tag->getName()) === 'authenticated'; |
| 135 | 135 | }); |
| 136 | 136 | |
@@ -202,25 +202,25 @@ discard block |
||
| 202 | 202 | { |
| 203 | 203 | $faker = Factory::create(); |
| 204 | 204 | $fakes = [ |
| 205 | - 'integer' => function () { |
|
| 205 | + 'integer' => function() { |
|
| 206 | 206 | return rand(1, 20); |
| 207 | 207 | }, |
| 208 | - 'number' => function () use ($faker) { |
|
| 208 | + 'number' => function() use ($faker) { |
|
| 209 | 209 | return $faker->randomFloat(); |
| 210 | 210 | }, |
| 211 | - 'float' => function () use ($faker) { |
|
| 211 | + 'float' => function() use ($faker) { |
|
| 212 | 212 | return $faker->randomFloat(); |
| 213 | 213 | }, |
| 214 | - 'boolean' => function () use ($faker) { |
|
| 214 | + 'boolean' => function() use ($faker) { |
|
| 215 | 215 | return $faker->boolean(); |
| 216 | 216 | }, |
| 217 | - 'string' => function () use ($faker) { |
|
| 217 | + 'string' => function() use ($faker) { |
|
| 218 | 218 | return str_random(); |
| 219 | 219 | }, |
| 220 | - 'array' => function () { |
|
| 220 | + 'array' => function() { |
|
| 221 | 221 | return '[]'; |
| 222 | 222 | }, |
| 223 | - 'object' => function () { |
|
| 223 | + 'object' => function() { |
|
| 224 | 224 | return '{}'; |
| 225 | 225 | }, |
| 226 | 226 | ]; |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | $parsedRoutes = $this->processRoutes($generator, $routes); |
| 60 | 60 | $parsedRoutes = collect($parsedRoutes)->groupBy('group') |
| 61 | - ->sort(function ($a, $b) { |
|
| 61 | + ->sort(function($a, $b) { |
|
| 62 | 62 | return strcmp($a->first()['group'], $b->first()['group']); |
| 63 | 63 | }); |
| 64 | 64 | |
@@ -73,17 +73,17 @@ discard block |
||
| 73 | 73 | private function writeMarkdown($parsedRoutes) |
| 74 | 74 | { |
| 75 | 75 | $outputPath = config('apidoc.output'); |
| 76 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
| 77 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
| 78 | - $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md'; |
|
| 79 | - $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md'; |
|
| 76 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
| 77 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
| 78 | + $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md'; |
|
| 79 | + $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md'; |
|
| 80 | 80 | |
| 81 | 81 | $infoText = view('apidoc::partials.info') |
| 82 | 82 | ->with('outputPath', ltrim($outputPath, 'public/')) |
| 83 | 83 | ->with('showPostmanCollectionButton', config('apidoc.postman')); |
| 84 | 84 | |
| 85 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
| 86 | - return $routeGroup->map(function ($route) { |
|
| 85 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
| 86 | + return $routeGroup->map(function($route) { |
|
| 87 | 87 | $route['output'] = (string) view('apidoc::partials.route')->with('route', $route)->render(); |
| 88 | 88 | |
| 89 | 89 | return $route; |
@@ -103,16 +103,16 @@ discard block |
||
| 103 | 103 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 107 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 108 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
| 109 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
| 106 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 107 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 108 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
|
| 109 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
|
| 110 | 110 | if ($routeDocumentationChanged === false || $this->option('force')) { |
| 111 | 111 | if ($routeDocumentationChanged) { |
| 112 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
| 112 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
| 113 | 113 | } |
| 114 | 114 | } else { |
| 115 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
| 115 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
| 116 | 116 | $route['modified_output'] = $existingRouteDoc[0]; |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -123,9 +123,9 @@ discard block |
||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | $prependFileContents = file_exists($prependFile) |
| 126 | - ? file_get_contents($prependFile)."\n" : ''; |
|
| 126 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
| 127 | 127 | $appendFileContents = file_exists($appendFile) |
| 128 | - ? "\n".file_get_contents($appendFile) : ''; |
|
| 128 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
| 129 | 129 | |
| 130 | 130 | $documentarian = new Documentarian(); |
| 131 | 131 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | ->with('showPostmanCollectionButton', config('apidoc.postman')) |
| 140 | 140 | ->with('parsedRoutes', $parsedRouteOutput); |
| 141 | 141 | |
| 142 | - if (! is_dir($outputPath)) { |
|
| 142 | + if (!is_dir($outputPath)) { |
|
| 143 | 143 | $documentarian->create($outputPath); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -159,18 +159,18 @@ discard block |
||
| 159 | 159 | |
| 160 | 160 | file_put_contents($compareFile, $compareMarkdown); |
| 161 | 161 | |
| 162 | - $this->info('Wrote index.md to: '.$outputPath); |
|
| 162 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
| 163 | 163 | |
| 164 | 164 | $this->info('Generating API HTML code'); |
| 165 | 165 | |
| 166 | 166 | $documentarian->generate($outputPath); |
| 167 | 167 | |
| 168 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
| 168 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
| 169 | 169 | |
| 170 | 170 | if (config('apidoc.postman')) { |
| 171 | 171 | $this->info('Generating Postman collection'); |
| 172 | 172 | |
| 173 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
| 173 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
| 174 | 174 | } |
| 175 | 175 | } |
| 176 | 176 | |
@@ -188,9 +188,9 @@ discard block |
||
| 188 | 188 | /** @var Route $route */ |
| 189 | 189 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
| 190 | 190 | $parsedRoutes[] = $generator->processRoute($route, $routeItem['apply']); |
| 191 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
| 191 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
| 192 | 192 | } else { |
| 193 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
| 193 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
| 194 | 194 | } |
| 195 | 195 | } |
| 196 | 196 | |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | */ |
| 205 | 205 | private function isValidRoute(Route $route) |
| 206 | 206 | { |
| 207 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
| 207 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | /** |
@@ -221,7 +221,7 @@ discard block |
||
| 221 | 221 | $phpdoc = new DocBlock($comment); |
| 222 | 222 | |
| 223 | 223 | return collect($phpdoc->getTags()) |
| 224 | - ->filter(function ($tag) use ($route) { |
|
| 224 | + ->filter(function($tag) use ($route) { |
|
| 225 | 225 | return $tag->getName() === 'hideFromAPIDocumentation'; |
| 226 | 226 | }) |
| 227 | 227 | ->isEmpty(); |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | protected function getTransformerResponse(array $tags) |
| 31 | 31 | { |
| 32 | 32 | try { |
| 33 | - if(empty($transformerTag = $this->getTransformerTag($tags))) { |
|
| 33 | + if (empty($transformerTag = $this->getTransformerTag($tags))) { |
|
| 34 | 34 | return; |
| 35 | 35 | } |
| 36 | 36 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod) |
| 69 | 69 | { |
| 70 | - $modelTag = array_first(array_filter($tags, function ($tag) { |
|
| 70 | + $modelTag = array_first(array_filter($tags, function($tag) { |
|
| 71 | 71 | return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel'; |
| 72 | 72 | })); |
| 73 | 73 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $type = $modelTag->getContent(); |
| 77 | 77 | } else { |
| 78 | 78 | $parameter = array_first($transformerMethod->getParameters()); |
| 79 | - if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) { |
|
| 79 | + if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) { |
|
| 80 | 80 | // ladies and gentlemen, we have a type! |
| 81 | 81 | $type = (string) $parameter->getType(); |
| 82 | 82 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | private function getTransformerTag(array $tags) |
| 123 | 123 | { |
| 124 | - $transFormerTags = array_filter($tags, function ($tag) { |
|
| 124 | + $transFormerTags = array_filter($tags, function($tag) { |
|
| 125 | 125 | return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']); |
| 126 | 126 | }); |
| 127 | 127 | |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | public function __invoke(Route $route, array $tags, array $rulesToApply) |
| 16 | 16 | { |
| 17 | 17 | $rulesToApply = $rulesToApply['response_calls'] ?? []; |
| 18 | - if (! $this->shouldMakeApiCall($route, $rulesToApply)) { |
|
| 18 | + if (!$this->shouldMakeApiCall($route, $rulesToApply)) { |
|
| 19 | 19 | return; |
| 20 | 20 | } |
| 21 | 21 | |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | |
| 132 | 132 | // the response from the Dingo dispatcher is the 'raw' response from the controller, |
| 133 | 133 | // so we have to ensure it's JSON first |
| 134 | - if (! $response instanceof Response) { |
|
| 134 | + if (!$response instanceof Response) { |
|
| 135 | 135 | $response = response()->json($response); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | $prefix = 'HTTP_'; |
| 235 | 235 | foreach ($headers as $name => $value) { |
| 236 | 236 | $name = strtr(strtoupper($name), '-', '_'); |
| 237 | - if (! starts_with($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 238 | - $name = $prefix.$name; |
|
| 237 | + if (!starts_with($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 238 | + $name = $prefix . $name; |
|
| 239 | 239 | } |
| 240 | 240 | $server[$name] = $value; |
| 241 | 241 | } |
@@ -24,7 +24,7 @@ |
||
| 24 | 24 | */ |
| 25 | 25 | protected function getDocBlockResponse(array $tags) |
| 26 | 26 | { |
| 27 | - $responseTags = array_filter($tags, function ($tag) { |
|
| 27 | + $responseTags = array_filter($tags, function($tag) { |
|
| 28 | 28 | return $tag instanceof Tag && strtolower($tag->getName()) == 'response'; |
| 29 | 29 | }); |
| 30 | 30 | if (empty($responseTags)) { |