@@ -114,8 +114,8 @@ discard block |
||
| 114 | 114 | $generatedDocumentation = file_get_contents($targetFile); |
| 115 | 115 | $compareDocumentation = file_get_contents($compareFile); |
| 116 | 116 | |
| 117 | - $parsedRouteOutput->transform(function (Collection $routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 118 | - return $routeGroup->transform(function (array $route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 117 | + $parsedRouteOutput->transform(function(Collection $routeGroup) use ($generatedDocumentation, $compareDocumentation) { |
|
| 118 | + return $routeGroup->transform(function(array $route) use ($generatedDocumentation, $compareDocumentation) { |
|
| 119 | 119 | if (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $generatedDocumentation, $existingRouteDoc)) { |
| 120 | 120 | $routeDocumentationChanged = (preg_match('/<!-- START_' . $route['id'] . ' -->(.*)<!-- END_' . $route['id'] . ' -->/is', $compareDocumentation, $lastDocWeGeneratedForThisRoute) && $lastDocWeGeneratedForThisRoute[1] !== $existingRouteDoc[1]); |
| 121 | 121 | if ($routeDocumentationChanged === false || $this->forceIt) { |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | $this->output->info('Writing index.md and source files to: ' . $this->sourceOutputPath); |
| 150 | 150 | |
| 151 | - if (! is_dir($this->sourceOutputPath)) { |
|
| 151 | + if (!is_dir($this->sourceOutputPath)) { |
|
| 152 | 152 | $documentarian = new Documentarian(); |
| 153 | 153 | $documentarian->create($this->sourceOutputPath); |
| 154 | 154 | } |
@@ -174,14 +174,14 @@ discard block |
||
| 174 | 174 | |
| 175 | 175 | public function generateMarkdownOutputForEachRoute(Collection $parsedRoutes, array $settings): Collection |
| 176 | 176 | { |
| 177 | - $parsedRouteOutput = $parsedRoutes->map(function (Collection $routeGroup) use ($settings) { |
|
| 178 | - return $routeGroup->map(function (array $route) use ($settings) { |
|
| 179 | - if (count($route['cleanBodyParameters']) && ! isset($route['headers']['Content-Type'])) { |
|
| 177 | + $parsedRouteOutput = $parsedRoutes->map(function(Collection $routeGroup) use ($settings) { |
|
| 178 | + return $routeGroup->map(function(array $route) use ($settings) { |
|
| 179 | + if (count($route['cleanBodyParameters']) && !isset($route['headers']['Content-Type'])) { |
|
| 180 | 180 | // Set content type if the user forgot to set it |
| 181 | 181 | $route['headers']['Content-Type'] = 'application/json'; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - $hasRequestOptions = ! empty($route['headers']) || ! empty($route['cleanQueryParameters']) || ! empty($route['cleanBodyParameters']); |
|
| 184 | + $hasRequestOptions = !empty($route['headers']) || !empty($route['cleanQueryParameters']) || !empty($route['cleanBodyParameters']); |
|
| 185 | 185 | $route['output'] = (string) view('apidoc::partials.route') |
| 186 | 186 | ->with('hasRequestOptions', $hasRequestOptions) |
| 187 | 187 | ->with('route', $route) |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | protected function copyAssetsFromSourceFolderToPublicFolder(): void |
| 254 | 254 | { |
| 255 | 255 | $publicPath = 'public/docs'; |
| 256 | - if (! is_dir($publicPath)) { |
|
| 256 | + if (!is_dir($publicPath)) { |
|
| 257 | 257 | mkdir($publicPath, 0777, true); |
| 258 | 258 | mkdir("{$publicPath}/css"); |
| 259 | 259 | mkdir("{$publicPath}/js"); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | rename("{$this->sourceOutputPath}/index.html", "{$this->outputPath}/index.html"); |
| 275 | 275 | } else { |
| 276 | 276 | // Move output to resources/views |
| 277 | - if (! is_dir($this->outputPath)) { |
|
| 277 | + if (!is_dir($this->outputPath)) { |
|
| 278 | 278 | mkdir($this->outputPath); |
| 279 | 279 | } |
| 280 | 280 | rename("{$this->sourceOutputPath}/index.html", "$this->outputPath/index.blade.php"); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | 'description' => config('apidoc.postman.description') ?: '', |
| 54 | 54 | 'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json', |
| 55 | 55 | ], |
| 56 | - 'item' => $this->routeGroups->map(function (Collection $routes, $groupName) { |
|
| 56 | + 'item' => $this->routeGroups->map(function(Collection $routes, $groupName) { |
|
| 57 | 57 | return [ |
| 58 | 58 | 'name' => $groupName, |
| 59 | 59 | 'description' => $routes->first()['metadata']['groupDescription'], |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | })->values()->toArray(), |
| 63 | 63 | ]; |
| 64 | 64 | |
| 65 | - if (! empty($this->auth)) { |
|
| 65 | + if (!empty($this->auth)) { |
|
| 66 | 66 | $collection['auth'] = $this->auth; |
| 67 | 67 | } |
| 68 | 68 | |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | // Exclude authentication headers if they're handled by Postman auth |
| 99 | 99 | $authHeader = $this->getAuthHeader(); |
| 100 | - if (! empty($authHeader)) { |
|
| 100 | + if (!empty($authHeader)) { |
|
| 101 | 101 | $headers = $headers->except($authHeader); |
| 102 | 102 | } |
| 103 | 103 | |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | ->union([ |
| 106 | 106 | 'Accept' => 'application/json', |
| 107 | 107 | ]) |
| 108 | - ->map(function ($value, $header) { |
|
| 108 | + ->map(function($value, $header) { |
|
| 109 | 109 | return [ |
| 110 | 110 | 'key' => $header, |
| 111 | 111 | 'value' => $value, |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | { |
| 120 | 120 | // URL Parameters are collected by the `UrlParameters` strategies, but only make sense if they're in the route |
| 121 | 121 | // definition. Filter out any URL parameters that don't appear in the URL. |
| 122 | - $urlParams = collect($route['urlParameters'])->filter(function ($_, $key) use ($route) { |
|
| 122 | + $urlParams = collect($route['urlParameters'])->filter(function($_, $key) use ($route) { |
|
| 123 | 123 | return Str::contains($route['uri'], '{' . $key . '}'); |
| 124 | 124 | }); |
| 125 | 125 | |
@@ -128,16 +128,16 @@ discard block |
||
| 128 | 128 | 'protocol' => $this->protocol, |
| 129 | 129 | 'host' => $this->baseUrl, |
| 130 | 130 | // Substitute laravel/symfony query params ({example}) to Postman style, prefixed with a colon |
| 131 | - 'path' => preg_replace_callback('/\/{(\w+)\??}(?=\/|$)/', function ($matches) { |
|
| 131 | + 'path' => preg_replace_callback('/\/{(\w+)\??}(?=\/|$)/', function($matches) { |
|
| 132 | 132 | return '/:' . $matches[1]; |
| 133 | 133 | }, $route['uri']), |
| 134 | - 'query' => collect($route['queryParameters'])->map(function ($parameter, $key) { |
|
| 134 | + 'query' => collect($route['queryParameters'])->map(function($parameter, $key) { |
|
| 135 | 135 | return [ |
| 136 | 136 | 'key' => $key, |
| 137 | 137 | 'value' => urlencode($parameter['value']), |
| 138 | 138 | 'description' => $parameter['description'], |
| 139 | 139 | // Default query params to disabled if they aren't required and have empty values |
| 140 | - 'disabled' => ! $parameter['required'] && empty($parameter['value']), |
|
| 140 | + 'disabled' => !$parameter['required'] && empty($parameter['value']), |
|
| 141 | 141 | ]; |
| 142 | 142 | })->values()->toArray(), |
| 143 | 143 | ]; |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | return $base; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - $base['variable'] = $urlParams->map(function ($parameter, $key) { |
|
| 151 | + $base['variable'] = $urlParams->map(function($parameter, $key) { |
|
| 152 | 152 | return [ |
| 153 | 153 | 'id' => $key, |
| 154 | 154 | 'key' => $key, |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | protected function getAuthHeader() |
| 164 | 164 | { |
| 165 | 165 | $auth = $this->auth; |
| 166 | - if (empty($auth) || ! is_string($auth['type'] ?? null)) { |
|
| 166 | + if (empty($auth) || !is_string($auth['type'] ?? null)) { |
|
| 167 | 167 | return null; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -14,25 +14,25 @@ |
||
| 14 | 14 | $faker->seed($this->config->get('faker_seed')); |
| 15 | 15 | } |
| 16 | 16 | $fakeFactories = [ |
| 17 | - 'integer' => function () use ($faker) { |
|
| 17 | + 'integer' => function() use ($faker) { |
|
| 18 | 18 | return $faker->numberBetween(1, 20); |
| 19 | 19 | }, |
| 20 | - 'number' => function () use ($faker) { |
|
| 20 | + 'number' => function() use ($faker) { |
|
| 21 | 21 | return $faker->randomFloat(); |
| 22 | 22 | }, |
| 23 | - 'float' => function () use ($faker) { |
|
| 23 | + 'float' => function() use ($faker) { |
|
| 24 | 24 | return $faker->randomFloat(); |
| 25 | 25 | }, |
| 26 | - 'boolean' => function () use ($faker) { |
|
| 26 | + 'boolean' => function() use ($faker) { |
|
| 27 | 27 | return $faker->boolean(); |
| 28 | 28 | }, |
| 29 | - 'string' => function () use ($faker) { |
|
| 29 | + 'string' => function() use ($faker) { |
|
| 30 | 30 | return $faker->word; |
| 31 | 31 | }, |
| 32 | - 'array' => function () { |
|
| 32 | + 'array' => function() { |
|
| 33 | 33 | return []; |
| 34 | 34 | }, |
| 35 | - 'object' => function () { |
|
| 35 | + 'object' => function() { |
|
| 36 | 36 | return new stdClass(); |
| 37 | 37 | }, |
| 38 | 38 | ]; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | private function getClassToBeTransformed(array $tags): string |
| 125 | 125 | { |
| 126 | - $modelTag = Arr::first(array_filter($tags, function ($tag) { |
|
| 126 | + $modelTag = Arr::first(array_filter($tags, function($tag) { |
|
| 127 | 127 | return ($tag instanceof Tag) && strtolower($tag->getName()) == 'apiresourcemodel'; |
| 128 | 128 | })); |
| 129 | 129 | |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | private function getApiResourceTag(array $tags) |
| 185 | 185 | { |
| 186 | 186 | $apiResourceTags = array_values( |
| 187 | - array_filter($tags, function ($tag) { |
|
| 187 | + array_filter($tags, function($tag) { |
|
| 188 | 188 | return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['apiresource', 'apiresourcecollection']); |
| 189 | 189 | }) |
| 190 | 190 | ); |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $fractal = new Manager(); |
| 67 | 67 | |
| 68 | - if (! is_null(config('apidoc.fractal.serializer'))) { |
|
| 68 | + if (!is_null(config('apidoc.fractal.serializer'))) { |
|
| 69 | 69 | $fractal->setSerializer(app(config('apidoc.fractal.serializer'))); |
| 70 | 70 | } |
| 71 | 71 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod): string |
| 123 | 123 | { |
| 124 | - $modelTag = Arr::first(array_filter($tags, function ($tag) { |
|
| 124 | + $modelTag = Arr::first(array_filter($tags, function($tag) { |
|
| 125 | 125 | return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel'; |
| 126 | 126 | })); |
| 127 | 127 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | $type = $modelTag->getContent(); |
| 131 | 131 | } else { |
| 132 | 132 | $parameter = Arr::first($transformerMethod->getParameters()); |
| 133 | - if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists($parameter->getType()->getName())) { |
|
| 133 | + if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists($parameter->getType()->getName())) { |
|
| 134 | 134 | // Ladies and gentlemen, we have a type! |
| 135 | 135 | $type = $parameter->getType()->getName(); |
| 136 | 136 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | private function getTransformerTag(array $tags) |
| 192 | 192 | { |
| 193 | 193 | $transformerTags = array_values( |
| 194 | - array_filter($tags, function ($tag) { |
|
| 194 | + array_filter($tags, function($tag) { |
|
| 195 | 195 | return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']); |
| 196 | 196 | }) |
| 197 | 197 | ); |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | public function __invoke(Route $route, \ReflectionClass $controller, \ReflectionMethod $method, array $routeRules, array $context = []) |
| 32 | 32 | { |
| 33 | 33 | $rulesToApply = $routeRules['response_calls'] ?? []; |
| 34 | - if (! $this->shouldMakeApiCall($route, $rulesToApply, $context)) { |
|
| 34 | + if (!$this->shouldMakeApiCall($route, $rulesToApply, $context)) { |
|
| 35 | 35 | return null; |
| 36 | 36 | } |
| 37 | 37 | |
@@ -194,14 +194,14 @@ discard block |
||
| 194 | 194 | // set URL and query parameters |
| 195 | 195 | $uri = $request->getRequestUri(); |
| 196 | 196 | $query = $request->getQueryString(); |
| 197 | - if (! empty($query)) { |
|
| 197 | + if (!empty($query)) { |
|
| 198 | 198 | $uri .= "?$query"; |
| 199 | 199 | } |
| 200 | 200 | $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]); |
| 201 | 201 | |
| 202 | 202 | // the response from the Dingo dispatcher is the 'raw' response from the controller, |
| 203 | 203 | // so we have to ensure it's JSON first |
| 204 | - if (! $response instanceof Response) { |
|
| 204 | + if (!$response instanceof Response) { |
|
| 205 | 205 | $response = response()->json($response); |
| 206 | 206 | } |
| 207 | 207 | |
@@ -329,7 +329,7 @@ discard block |
||
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | // Don't attempt a response call if there are already successful responses |
| 332 | - $successResponses = collect($context['responses'])->filter(function ($response) { |
|
| 332 | + $successResponses = collect($context['responses'])->filter(function($response) { |
|
| 333 | 333 | return ((string) $response['status'])[0] == '2'; |
| 334 | 334 | })->count(); |
| 335 | 335 | if ($successResponses) { |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | $prefix = 'HTTP_'; |
| 366 | 366 | foreach ($headers as $name => $value) { |
| 367 | 367 | $name = strtr(strtoupper($name), '-', '_'); |
| 368 | - if (! Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 368 | + if (!Str::startsWith($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
| 369 | 369 | $name = $prefix . $name; |
| 370 | 370 | } |
| 371 | 371 | $server[$name] = $value; |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | { |
| 45 | 45 | // Avoid "holes" in the keys of the filtered array, by using array_values on the filtered array |
| 46 | 46 | $responseFileTags = array_values( |
| 47 | - array_filter($tags, function ($tag) { |
|
| 47 | + array_filter($tags, function($tag) { |
|
| 48 | 48 | return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile'; |
| 49 | 49 | }) |
| 50 | 50 | ); |
@@ -53,16 +53,16 @@ discard block |
||
| 53 | 53 | return null; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - $responses = array_map(function (Tag $responseFileTag) { |
|
| 56 | + $responses = array_map(function(Tag $responseFileTag) { |
|
| 57 | 57 | preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result); |
| 58 | 58 | $relativeFilePath = trim($result[2]); |
| 59 | 59 | $filePath = storage_path($relativeFilePath); |
| 60 | - if (! file_exists($filePath)) { |
|
| 60 | + if (!file_exists($filePath)) { |
|
| 61 | 61 | throw new \Exception('@responseFile ' . $relativeFilePath . ' does not exist'); |
| 62 | 62 | } |
| 63 | 63 | $status = $result[1] ?: 200; |
| 64 | 64 | $content = $result[2] ? file_get_contents($filePath, true) : '{}'; |
| 65 | - $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; |
|
| 65 | + $json = !empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; |
|
| 66 | 66 | $merged = array_merge(json_decode($content, true), json_decode($json, true)); |
| 67 | 67 | |
| 68 | 68 | return ['content' => json_encode($merged), 'status' => (int) $status]; |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | $responses = $this->fetchResponses($controller, $method, $route, $routeRules, $parsedRoute); |
| 85 | 85 | $parsedRoute['responses'] = $responses; |
| 86 | - $parsedRoute['showresponse'] = ! empty($responses); |
|
| 86 | + $parsedRoute['showresponse'] = !empty($responses); |
|
| 87 | 87 | |
| 88 | 88 | return $parsedRoute; |
| 89 | 89 | } |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $responses = $this->iterateThroughStrategies('responses', $context, [$route, $controller, $method, $rulesToApply]); |
| 122 | 122 | if (count($responses)) { |
| 123 | - return array_filter($responses, function ($response) { |
|
| 123 | + return array_filter($responses, function($response) { |
|
| 124 | 124 | return $response['content'] != null; |
| 125 | 125 | }); |
| 126 | 126 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $strategyArgs = $arguments; |
| 171 | 171 | $strategyArgs[] = $context; |
| 172 | 172 | $results = $strategy(...$strategyArgs); |
| 173 | - if (! is_null($results)) { |
|
| 173 | + if (!is_null($results)) { |
|
| 174 | 174 | foreach ($results as $index => $item) { |
| 175 | 175 | if ($stage == 'responses') { |
| 176 | 176 | // Responses are additive |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | // and also allows values to be overwritten |
| 183 | 183 | |
| 184 | 184 | // Don't allow overwriting if an empty value is trying to replace a set one |
| 185 | - if (! in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) { |
|
| 185 | + if (!in_array($context[$stage], [null, ''], true) && in_array($item, [null, ''], true)) { |
|
| 186 | 186 | continue; |
| 187 | 187 | } else { |
| 188 | 188 | $context[$stage][$index] = $item; |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | $values = []; |
| 208 | 208 | |
| 209 | 209 | // Remove params which have no examples. |
| 210 | - $params = array_filter($params, function ($details) { |
|
| 211 | - return ! is_null($details['value']); |
|
| 210 | + $params = array_filter($params, function($details) { |
|
| 211 | + return !is_null($details['value']); |
|
| 212 | 212 | }); |
| 213 | 213 | |
| 214 | 214 | foreach ($params as $paramName => $details) { |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | public function handle() |
| 16 | 16 | { |
| 17 | 17 | $sourceOutputPath = 'resources/docs/source'; |
| 18 | - if (! is_dir($sourceOutputPath)) { |
|
| 18 | + if (!is_dir($sourceOutputPath)) { |
|
| 19 | 19 | $this->error('There is no existing documentation available at ' . $sourceOutputPath . '.'); |
| 20 | 20 | |
| 21 | 21 | return false; |