@@ -64,14 +64,14 @@ discard block |
||
| 64 | 64 | |
| 65 | 65 | private function getAllRoutes(bool $usingDingoRouter) |
| 66 | 66 | { |
| 67 | - if (! $usingDingoRouter) { |
|
| 67 | + if (!$usingDingoRouter) { |
|
| 68 | 68 | return RouteFacade::getRoutes(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes(); |
| 72 | 72 | |
| 73 | 73 | return collect($allRouteCollections) |
| 74 | - ->flatMap(function (RouteCollection $collection) { |
|
| 74 | + ->flatMap(function(RouteCollection $collection) { |
|
| 75 | 75 | return $collection->getRoutes(); |
| 76 | 76 | })->toArray(); |
| 77 | 77 | } |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter) |
| 80 | 80 | { |
| 81 | 81 | $matchesVersion = $usingDingoRouter |
| 82 | - ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
| 82 | + ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
| 83 | 83 | : true; |
| 84 | 84 | |
| 85 | 85 | return Str::is($mustIncludes, $route->getName()) |
@@ -20,7 +20,7 @@ |
||
| 20 | 20 | |
| 21 | 21 | $class = new ReflectionClass($className); |
| 22 | 22 | |
| 23 | - if (! $class->hasMethod($methodName)) { |
|
| 23 | + if (!$class->hasMethod($methodName)) { |
|
| 24 | 24 | throw new \Exception("Error while fetching docblock for route: Class $className does not contain method $methodName"); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | protected function getDocBlockResponses(array $tags) |
| 44 | 44 | { |
| 45 | 45 | $responseTags = array_values( |
| 46 | - array_filter($tags, function ($tag) { |
|
| 46 | + array_filter($tags, function($tag) { |
|
| 47 | 47 | return $tag instanceof Tag && strtolower($tag->getName()) === 'response'; |
| 48 | 48 | }) |
| 49 | 49 | ); |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | return null; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - $responses = array_map(function (Tag $responseTag) { |
|
| 55 | + $responses = array_map(function(Tag $responseTag) { |
|
| 56 | 56 | preg_match('/^(\d{3})?\s?([\s\S]*)$/', $responseTag->getContent(), $result); |
| 57 | 57 | |
| 58 | 58 | $status = $result[1] ?: 200; |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | private function getUrlParametersFromDocBlock($tags) |
| 56 | 56 | { |
| 57 | 57 | $parameters = collect($tags) |
| 58 | - ->filter(function ($tag) { |
|
| 58 | + ->filter(function($tag) { |
|
| 59 | 59 | return $tag instanceof Tag && $tag->getName() === 'urlParam'; |
| 60 | 60 | }) |
| 61 | - ->mapWithKeys(function (Tag $tag) { |
|
| 61 | + ->mapWithKeys(function(Tag $tag) { |
|
| 62 | 62 | // Format: |
| 63 | 63 | // @urlParam <name> <"required" (optional)> <description> |
| 64 | 64 | // Examples: |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | list($description, $value) = $this->parseParamDescription($description, 'string'); |
| 85 | - if (is_null($value) && ! $this->shouldExcludeExample($tag->getContent())) { |
|
| 85 | + if (is_null($value) && !$this->shouldExcludeExample($tag->getContent())) { |
|
| 86 | 86 | $value = Str::contains($description, ['number', 'count', 'page']) |
| 87 | 87 | ? $this->generateDummyValue('integer') |
| 88 | 88 | : $this->generateDummyValue('string'); |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | private function getQueryParametersFromDocBlock($tags) |
| 56 | 56 | { |
| 57 | 57 | $parameters = collect($tags) |
| 58 | - ->filter(function ($tag) { |
|
| 58 | + ->filter(function($tag) { |
|
| 59 | 59 | return $tag instanceof Tag && $tag->getName() === 'queryParam'; |
| 60 | 60 | }) |
| 61 | - ->mapWithKeys(function (Tag $tag) { |
|
| 61 | + ->mapWithKeys(function(Tag $tag) { |
|
| 62 | 62 | // Format: |
| 63 | 63 | // @queryParam <name> <"required" (optional)> <description> |
| 64 | 64 | // Examples: |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | list($description, $value) = $this->parseParamDescription($description, 'string'); |
| 85 | - if (is_null($value) && ! $this->shouldExcludeExample($tag->getContent())) { |
|
| 85 | + if (is_null($value) && !$this->shouldExcludeExample($tag->getContent())) { |
|
| 86 | 86 | $value = Str::contains($description, ['number', 'count', 'page']) |
| 87 | 87 | ? $this->generateDummyValue('integer') |
| 88 | 88 | : $this->generateDummyValue('string'); |
@@ -54,10 +54,10 @@ discard block |
||
| 54 | 54 | private function getBodyParametersFromDocBlock($tags) |
| 55 | 55 | { |
| 56 | 56 | $parameters = collect($tags) |
| 57 | - ->filter(function ($tag) { |
|
| 57 | + ->filter(function($tag) { |
|
| 58 | 58 | return $tag instanceof Tag && $tag->getName() === 'bodyParam'; |
| 59 | 59 | }) |
| 60 | - ->mapWithKeys(function (Tag $tag) { |
|
| 60 | + ->mapWithKeys(function(Tag $tag) { |
|
| 61 | 61 | // Format: |
| 62 | 62 | // @bodyParam <name> <type> <"required" (optional)> <description> |
| 63 | 63 | // Examples: |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $type = $this->normalizeParameterType($type); |
| 84 | 84 | list($description, $example) = $this->parseParamDescription($description, $type); |
| 85 | - $value = is_null($example) && ! $this->shouldExcludeExample($tag->getContent()) |
|
| 85 | + $value = is_null($example) && !$this->shouldExcludeExample($tag->getContent()) |
|
| 86 | 86 | ? $this->generateDummyValue($type) |
| 87 | 87 | : $example; |
| 88 | 88 | |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | Route::prefix($path) |
| 19 | 19 | ->namespace('\Mpociot\ApiDoc\Http') |
| 20 | 20 | ->middleware(static::middleware()) |
| 21 | - ->group(function () { |
|
| 21 | + ->group(function() { |
|
| 22 | 22 | Route::get('/', 'Controller@html')->name('apidoc'); |
| 23 | 23 | Route::get('.json', 'Controller@json')->name('apidoc.json'); |
| 24 | 24 | }); |
@@ -7,7 +7,7 @@ |
||
| 7 | 7 | |
| 8 | 8 | Route::namespace('\Mpociot\ApiDoc\Http') |
| 9 | 9 | ->middleware($middleware) |
| 10 | - ->group(function () use ($prefix) { |
|
| 10 | + ->group(function() use ($prefix) { |
|
| 11 | 11 | Route::get($prefix, 'Controller@html')->name('apidoc'); |
| 12 | 12 | Route::get("$prefix.json", 'Controller@json')->name('apidoc.json'); |
| 13 | 13 | }); |
@@ -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 | |