@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | /** |
| 27 | 27 | * @param Route $route |
| 28 | 28 | * |
| 29 | - * @return mixed |
|
| 29 | + * @return string |
|
| 30 | 30 | */ |
| 31 | 31 | public function getUri(Route $route) |
| 32 | 32 | { |
@@ -90,7 +90,6 @@ discard block |
||
| 90 | 90 | /** |
| 91 | 91 | * Prepares / Disables route middlewares. |
| 92 | 92 | * |
| 93 | - * @param bool $disable |
|
| 94 | 93 | * |
| 95 | 94 | * @return void |
| 96 | 95 | */ |
@@ -161,7 +160,7 @@ discard block |
||
| 161 | 160 | * @param $route |
| 162 | 161 | * @param array $bindings |
| 163 | 162 | * |
| 164 | - * @return mixed |
|
| 163 | + * @return string |
|
| 165 | 164 | */ |
| 166 | 165 | protected function addRouteModelBindings($route, $bindings) |
| 167 | 166 | { |
@@ -177,7 +176,7 @@ discard block |
||
| 177 | 176 | /** |
| 178 | 177 | * @param \Illuminate\Routing\Route $route |
| 179 | 178 | * |
| 180 | - * @return array |
|
| 179 | + * @return Route |
|
| 181 | 180 | */ |
| 182 | 181 | protected function getRouteDescription($route) |
| 183 | 182 | { |
@@ -260,7 +259,7 @@ discard block |
||
| 260 | 259 | /** |
| 261 | 260 | * @param $response |
| 262 | 261 | * |
| 263 | - * @return mixed |
|
| 262 | + * @return Route |
|
| 264 | 263 | */ |
| 265 | 264 | private function getResponseContent($response) |
| 266 | 265 | { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $response = $docblockResponse; |
| 64 | 64 | $showresponse = true; |
| 65 | 65 | } |
| 66 | - if (! $response) { |
|
| 66 | + if (!$response) { |
|
| 67 | 67 | $transformerResponse = $this->getTransformerResponse($routeDescription['tags']); |
| 68 | 68 | if ($transformerResponse) { |
| 69 | 69 | // we have a transformer response from the docblock ( @transformer || @transformercollection ) |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $content = $this->getResponseContent($response); |
| 76 | 76 | |
| 77 | 77 | return [ |
| 78 | - 'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))), |
|
| 78 | + 'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))), |
|
| 79 | 79 | 'resource' => $routeGroup, |
| 80 | 80 | 'title' => $routeDescription['short'], |
| 81 | 81 | 'description' => $routeDescription['long'], |
@@ -105,8 +105,8 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | protected function getDocblockResponse($tags) |
| 107 | 107 | { |
| 108 | - $responseTags = array_filter($tags, function ($tag) { |
|
| 109 | - if (! ($tag instanceof Tag)) { |
|
| 108 | + $responseTags = array_filter($tags, function($tag) { |
|
| 109 | + if (!($tag instanceof Tag)) { |
|
| 110 | 110 | return false; |
| 111 | 111 | } |
| 112 | 112 | |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | $methods = $this->getMethods($route); |
| 144 | 144 | |
| 145 | 145 | // Split headers into key - value pairs |
| 146 | - $headers = collect($headers)->map(function ($value) { |
|
| 146 | + $headers = collect($headers)->map(function($value) { |
|
| 147 | 147 | $split = explode(':', $value); // explode to get key + values |
| 148 | 148 | $key = array_shift($split); // extract the key and keep the values in the array |
| 149 | 149 | $value = implode(':', $split); // implode values into string again |
@@ -167,8 +167,8 @@ discard block |
||
| 167 | 167 | { |
| 168 | 168 | $uri = $this->getUri($route); |
| 169 | 169 | foreach ($bindings as $model => $id) { |
| 170 | - $uri = str_replace('{'.$model.'}', $id, $uri); |
|
| 171 | - $uri = str_replace('{'.$model.'?}', $id, $uri); |
|
| 170 | + $uri = str_replace('{' . $model . '}', $id, $uri); |
|
| 171 | + $uri = str_replace('{' . $model . '?}', $id, $uri); |
|
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | return $uri; |
@@ -247,8 +247,8 @@ discard block |
||
| 247 | 247 | foreach ($headers as $name => $value) { |
| 248 | 248 | $name = strtr(strtoupper($name), '-', '_'); |
| 249 | 249 | |
| 250 | - if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 251 | - $name = $prefix.$name; |
|
| 250 | + if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 251 | + $name = $prefix . $name; |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | $server[$name] = $value; |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | protected function getTransformerResponse($tags) |
| 287 | 287 | { |
| 288 | 288 | try { |
| 289 | - $transFormerTags = array_filter($tags, function ($tag) { |
|
| 290 | - if (! ($tag instanceof Tag)) { |
|
| 289 | + $transFormerTags = array_filter($tags, function($tag) { |
|
| 290 | + if (!($tag instanceof Tag)) { |
|
| 291 | 291 | return false; |
| 292 | 292 | } |
| 293 | 293 | |
@@ -298,8 +298,8 @@ discard block |
||
| 298 | 298 | return false; |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | - $modelTag = array_first(array_filter($tags, function ($tag) { |
|
| 302 | - if (! ($tag instanceof Tag)) { |
|
| 301 | + $modelTag = array_first(array_filter($tags, function($tag) { |
|
| 302 | + if (!($tag instanceof Tag)) { |
|
| 303 | 303 | return false; |
| 304 | 304 | } |
| 305 | 305 | |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | })); |
| 308 | 308 | $tag = \array_first($transFormerTags); |
| 309 | 309 | $transformer = $tag->getContent(); |
| 310 | - if (! \class_exists($transformer)) { |
|
| 310 | + if (!\class_exists($transformer)) { |
|
| 311 | 311 | // if we can't find the transformer we can't generate a response |
| 312 | 312 | return; |
| 313 | 313 | } |
@@ -323,7 +323,7 @@ discard block |
||
| 323 | 323 | if (version_compare(PHP_VERSION, '7.0.0') >= 0 && \is_null($type)) { |
| 324 | 324 | // we can only get the type with reflection for PHP 7 |
| 325 | 325 | if ($parameter->hasType() && |
| 326 | - ! $parameter->getType()->isBuiltin() && |
|
| 326 | + !$parameter->getType()->isBuiltin() && |
|
| 327 | 327 | \class_exists((string) $parameter->getType())) { |
| 328 | 328 | //we have a type |
| 329 | 329 | $type = (string) $parameter->getType(); |
@@ -41,7 +41,6 @@ |
||
| 41 | 41 | /** |
| 42 | 42 | * Prepares / Disables route middlewares. |
| 43 | 43 | * |
| 44 | - * @param bool $disable |
|
| 45 | 44 | * |
| 46 | 45 | * @return void |
| 47 | 46 | */ |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | */ |
| 58 | 58 | public function prepareMiddleware($enable = true) |
| 59 | 59 | { |
| 60 | - App::instance('middleware.disable', ! $enable); |
|
| 60 | + App::instance('middleware.disable', !$enable); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
@@ -25,7 +25,7 @@ |
||
| 25 | 25 | { |
| 26 | 26 | $dispatcher = app('Dingo\Api\Dispatcher')->raw(); |
| 27 | 27 | |
| 28 | - collect($server)->map(function ($key, $value) use ($dispatcher) { |
|
| 28 | + collect($server)->map(function($key, $value) use ($dispatcher) { |
|
| 29 | 29 | $dispatcher->header($value, $key); |
| 30 | 30 | }); |
| 31 | 31 | |
@@ -18,11 +18,11 @@ |
||
| 18 | 18 | $this->loadViewsFrom(__DIR__ . '/../resources/views/', 'apidoc'); |
| 19 | 19 | |
| 20 | 20 | $this->publishes([ |
| 21 | - __DIR__ . '/../resources/views' => app()->basePath().'/resources/views/vendor/apidoc', |
|
| 21 | + __DIR__ . '/../resources/views' => app()->basePath() . '/resources/views/vendor/apidoc', |
|
| 22 | 22 | ], 'views'); |
| 23 | 23 | |
| 24 | 24 | $this->publishes([ |
| 25 | - __DIR__.'/../config/apidoc.php' => config_path('apidoc.php'), |
|
| 25 | + __DIR__ . '/../config/apidoc.php' => config_path('apidoc.php'), |
|
| 26 | 26 | ], 'config'); |
| 27 | 27 | |
| 28 | 28 | if ($this->app->runningInConsole()) { |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | { |
| 11 | 11 | public function getDingoRoutesToBeDocumented(array $routeRules) |
| 12 | 12 | { |
| 13 | - return $this->getRoutesToBeDocumented($routeRules,true); |
|
| 13 | + return $this->getRoutesToBeDocumented($routeRules, true); |
|
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function getLaravelRoutesToBeDocumented(array $routeRules) |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | |
| 55 | 55 | $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes(); |
| 56 | 56 | return collect($allRouteCollections) |
| 57 | - ->flatMap(function (RouteCollection $collection) { |
|
| 57 | + ->flatMap(function(RouteCollection $collection) { |
|
| 58 | 58 | return $collection->getRoutes(); |
| 59 | 59 | })->toArray(); |
| 60 | 60 | } |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | |
| 62 | 62 | $parsedRoutes = $this->processRoutes($generator, $routes); |
| 63 | 63 | $parsedRoutes = collect($parsedRoutes)->groupBy('resource') |
| 64 | - ->sort(function ($a, $b) { |
|
| 64 | + ->sort(function($a, $b) { |
|
| 65 | 65 | return strcmp($a->first()['resource'], $b->first()['resource']); |
| 66 | 66 | }); |
| 67 | 67 | |
@@ -76,17 +76,17 @@ discard block |
||
| 76 | 76 | private function writeMarkdown($parsedRoutes) |
| 77 | 77 | { |
| 78 | 78 | $outputPath = $this->option('output'); |
| 79 | - $targetFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'index.md'; |
|
| 80 | - $compareFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'.compare.md'; |
|
| 81 | - $prependFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'prepend.md'; |
|
| 82 | - $appendFile = $outputPath.DIRECTORY_SEPARATOR.'source'.DIRECTORY_SEPARATOR.'append.md'; |
|
| 79 | + $targetFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'index.md'; |
|
| 80 | + $compareFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . '.compare.md'; |
|
| 81 | + $prependFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'prepend.md'; |
|
| 82 | + $appendFile = $outputPath . DIRECTORY_SEPARATOR . 'source' . DIRECTORY_SEPARATOR . 'append.md'; |
|
| 83 | 83 | |
| 84 | 84 | $infoText = view('apidoc::partials.info') |
| 85 | 85 | ->with('outputPath', ltrim($outputPath, 'public/')) |
| 86 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')); |
|
| 86 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')); |
|
| 87 | 87 | |
| 88 | - $parsedRouteOutput = $parsedRoutes->map(function ($routeGroup) { |
|
| 89 | - return $routeGroup->map(function ($route) { |
|
| 88 | + $parsedRouteOutput = $parsedRoutes->map(function($routeGroup) { |
|
| 89 | + return $routeGroup->map(function($route) { |
|
| 90 | 90 | $route['output'] = (string) view('apidoc::partials.route')->with('parsedRoute', $route)->render(); |
| 91 | 91 | |
| 92 | 92 | return $route; |
@@ -106,16 +106,16 @@ discard block |
||
| 106 | 106 | $frontmatter = trim($generatedFrontmatter[1], "\n"); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - $parsedRouteOutput->transform(function ($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 110 | - return $routeGroup->transform(function ($route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 111 | - if (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $generatedDocumentation, $routeMatch)) { |
|
| 112 | - $routeDocumentationChanged = (preg_match('/<!-- START_'.$route['id'].' -->(.*)<!-- END_'.$route['id'].' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
| 109 | + $parsedRouteOutput->transform(function($routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 110 | + return $routeGroup->transform(function($route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 111 | + if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $routeMatch)) { |
|
| 112 | + $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $compareMatch) && $compareMatch[1] !== $routeMatch[1]); |
|
| 113 | 113 | if ($routeDocumentationChanged === false || $this->option('force')) { |
| 114 | 114 | if ($routeDocumentationChanged) { |
| 115 | - $this->warn('Discarded manual changes for route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
| 115 | + $this->warn('Discarded manual changes for route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
| 116 | 116 | } |
| 117 | 117 | } else { |
| 118 | - $this->warn('Skipping modified route ['.implode(',', $route['methods']).'] '.$route['uri']); |
|
| 118 | + $this->warn('Skipping modified route [' . implode(',', $route['methods']) . '] ' . $route['uri']); |
|
| 119 | 119 | $route['modified_output'] = $routeMatch[0]; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -126,9 +126,9 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | $prependFileContents = file_exists($prependFile) |
| 129 | - ? file_get_contents($prependFile)."\n" : ''; |
|
| 129 | + ? file_get_contents($prependFile) . "\n" : ''; |
|
| 130 | 130 | $appendFileContents = file_exists($appendFile) |
| 131 | - ? "\n".file_get_contents($appendFile) : ''; |
|
| 131 | + ? "\n" . file_get_contents($appendFile) : ''; |
|
| 132 | 132 | |
| 133 | 133 | $documentarian = new Documentarian(); |
| 134 | 134 | |
@@ -139,10 +139,10 @@ discard block |
||
| 139 | 139 | ->with('prependMd', $prependFileContents) |
| 140 | 140 | ->with('appendMd', $appendFileContents) |
| 141 | 141 | ->with('outputPath', $this->option('output')) |
| 142 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
| 142 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
| 143 | 143 | ->with('parsedRoutes', $parsedRouteOutput); |
| 144 | 144 | |
| 145 | - if (! is_dir($outputPath)) { |
|
| 145 | + if (!is_dir($outputPath)) { |
|
| 146 | 146 | $documentarian->create($outputPath); |
| 147 | 147 | } |
| 148 | 148 | |
@@ -157,23 +157,23 @@ discard block |
||
| 157 | 157 | ->with('prependMd', $prependFileContents) |
| 158 | 158 | ->with('appendMd', $appendFileContents) |
| 159 | 159 | ->with('outputPath', $this->option('output')) |
| 160 | - ->with('showPostmanCollectionButton', ! $this->option('noPostmanCollection')) |
|
| 160 | + ->with('showPostmanCollectionButton', !$this->option('noPostmanCollection')) |
|
| 161 | 161 | ->with('parsedRoutes', $parsedRouteOutput); |
| 162 | 162 | |
| 163 | 163 | file_put_contents($compareFile, $compareMarkdown); |
| 164 | 164 | |
| 165 | - $this->info('Wrote index.md to: '.$outputPath); |
|
| 165 | + $this->info('Wrote index.md to: ' . $outputPath); |
|
| 166 | 166 | |
| 167 | 167 | $this->info('Generating API HTML code'); |
| 168 | 168 | |
| 169 | 169 | $documentarian->generate($outputPath); |
| 170 | 170 | |
| 171 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
| 171 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
| 172 | 172 | |
| 173 | 173 | if ($this->option('noPostmanCollection') !== true) { |
| 174 | 174 | $this->info('Generating Postman collection'); |
| 175 | 175 | |
| 176 | - file_put_contents($outputPath.DIRECTORY_SEPARATOR.'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
| 176 | + file_put_contents($outputPath . DIRECTORY_SEPARATOR . 'collection.json', $this->generatePostmanCollection($parsedRoutes)); |
|
| 177 | 177 | } |
| 178 | 178 | } |
| 179 | 179 | |
@@ -191,9 +191,9 @@ discard block |
||
| 191 | 191 | /** @var Route $route */ |
| 192 | 192 | if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) { |
| 193 | 193 | $parsedRoutes[] = $generator->processRoute($route, $apply); |
| 194 | - $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
| 194 | + $this->info('Processed route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
| 195 | 195 | } else { |
| 196 | - $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route)); |
|
| 196 | + $this->warn('Skipping route: [' . implode(',', $generator->getMethods($route)) . '] ' . $generator->getUri($route)); |
|
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | */ |
| 208 | 208 | private function isValidRoute(Route $route) |
| 209 | 209 | { |
| 210 | - return ! is_callable($route->getAction()['uses']) && ! is_null($route->getAction()['uses']); |
|
| 210 | + return !is_callable($route->getAction()['uses']) && !is_null($route->getAction()['uses']); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | /** |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $phpdoc = new DocBlock($comment); |
| 225 | 225 | |
| 226 | 226 | return collect($phpdoc->getTags()) |
| 227 | - ->filter(function ($tag) use ($route) { |
|
| 227 | + ->filter(function($tag) use ($route) { |
|
| 228 | 228 | return $tag->getName() === 'hideFromAPIDocumentation'; |
| 229 | 229 | }) |
| 230 | 230 | ->isEmpty(); |
@@ -44,8 +44,8 @@ discard block |
||
| 44 | 44 | |
| 45 | 45 | $documentarian = new Documentarian(); |
| 46 | 46 | |
| 47 | - if (! is_dir($outputPath)) { |
|
| 48 | - $this->error('There is no generated documentation available at '.$outputPath.'.'); |
|
| 47 | + if (!is_dir($outputPath)) { |
|
| 48 | + $this->error('There is no generated documentation available at ' . $outputPath . '.'); |
|
| 49 | 49 | |
| 50 | 50 | return false; |
| 51 | 51 | } |
@@ -53,6 +53,6 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | $documentarian->generate($outputPath); |
| 55 | 55 | |
| 56 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
| 56 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
| 57 | 57 | } |
| 58 | 58 | } |
@@ -32,11 +32,11 @@ discard block |
||
| 32 | 32 | 'description' => '', |
| 33 | 33 | 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json', |
| 34 | 34 | ], |
| 35 | - 'item' => $this->routeGroups->map(function ($routes, $groupName) { |
|
| 35 | + 'item' => $this->routeGroups->map(function($routes, $groupName) { |
|
| 36 | 36 | return [ |
| 37 | 37 | 'name' => $groupName, |
| 38 | 38 | 'description' => '', |
| 39 | - 'item' => $routes->map(function ($route) { |
|
| 39 | + 'item' => $routes->map(function($route) { |
|
| 40 | 40 | return [ |
| 41 | 41 | 'name' => $route['title'] != '' ? $route['title'] : url($route['uri']), |
| 42 | 42 | 'request' => [ |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | 'method' => $route['methods'][0], |
| 45 | 45 | 'body' => [ |
| 46 | 46 | 'mode' => 'formdata', |
| 47 | - 'formdata' => collect($route['parameters'])->map(function ($parameter, $key) { |
|
| 47 | + 'formdata' => collect($route['parameters'])->map(function($parameter, $key) { |
|
| 48 | 48 | return [ |
| 49 | 49 | 'key' => $key, |
| 50 | 50 | 'value' => isset($parameter['value']) ? $parameter['value'] : '', |