@@ -42,15 +42,15 @@ |
||
42 | 42 | |
43 | 43 | $documentarian = new Documentarian(); |
44 | 44 | |
45 | - if (! is_dir($outputPath)) { |
|
46 | - $this->error('There is no existing documentation available at '.$outputPath.'.'); |
|
45 | + if (!is_dir($outputPath)) { |
|
46 | + $this->error('There is no existing documentation available at ' . $outputPath . '.'); |
|
47 | 47 | |
48 | 48 | return false; |
49 | 49 | } |
50 | - $this->info('Rebuilding API HTML code from '.$outputPath.'/source/index.md'); |
|
50 | + $this->info('Rebuilding API HTML code from ' . $outputPath . '/source/index.md'); |
|
51 | 51 | |
52 | 52 | $documentarian->generate($outputPath); |
53 | 53 | |
54 | - $this->info('Wrote HTML documentation to: '.$outputPath.'/index.html'); |
|
54 | + $this->info('Wrote HTML documentation to: ' . $outputPath . '/index.html'); |
|
55 | 55 | } |
56 | 56 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | * @param Route $route |
64 | 64 | * @param array $bindings |
65 | 65 | * |
66 | - * @return mixed |
|
66 | + * @return string |
|
67 | 67 | */ |
68 | 68 | protected function replaceUrlParameterBindings(Route $route, $bindings) |
69 | 69 | { |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | public function __invoke(Route $route, array $tags, array $routeProps) |
16 | 16 | { |
17 | 17 | $rulesToApply = $routeProps['rules']['response_calls'] ?? []; |
18 | - if (! $this->shouldMakeApiCall($route, $rulesToApply)) { |
|
18 | + if (!$this->shouldMakeApiCall($route, $rulesToApply)) { |
|
19 | 19 | return; |
20 | 20 | } |
21 | 21 | |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | // set URL and query parameters |
125 | 125 | $uri = $request->getRequestUri(); |
126 | 126 | $query = $request->getQueryString(); |
127 | - if (! empty($query)) { |
|
127 | + if (!empty($query)) { |
|
128 | 128 | $uri .= "?$query"; |
129 | 129 | } |
130 | 130 | $response = call_user_func_array([$dispatcher, strtolower($request->method())], [$uri]); |
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 | |
@@ -238,8 +238,8 @@ discard block |
||
238 | 238 | $prefix = 'HTTP_'; |
239 | 239 | foreach ($headers as $name => $value) { |
240 | 240 | $name = strtr(strtoupper($name), '-', '_'); |
241 | - if (! starts_with($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
242 | - $name = $prefix.$name; |
|
241 | + if (!starts_with($name, $prefix) && $name !== 'CONTENT_TYPE') { |
|
242 | + $name = $prefix . $name; |
|
243 | 243 | } |
244 | 244 | $server[$name] = $value; |
245 | 245 | } |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * @param Route $route |
16 | 16 | * |
17 | - * @return mixed |
|
17 | + * @return string |
|
18 | 18 | */ |
19 | 19 | public function getUri(Route $route) |
20 | 20 | { |
@@ -33,7 +33,6 @@ discard block |
||
33 | 33 | |
34 | 34 | /** |
35 | 35 | * @param \Illuminate\Routing\Route $route |
36 | - * @param array $apply Rules to apply when generating documentation for this route |
|
37 | 36 | * |
38 | 37 | * @return array |
39 | 38 | */ |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | ]); |
59 | 59 | |
60 | 60 | $parsedRoute = [ |
61 | - 'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))), |
|
61 | + 'id' => md5($this->getUri($route) . ':' . implode($this->getMethods($route))), |
|
62 | 62 | 'group' => $routeGroup, |
63 | 63 | 'title' => $docBlock['short'], |
64 | 64 | 'description' => $docBlock['long'], |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'queryParameters' => $queryParameters, |
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 | |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | { |
81 | 81 | /** @var ReflectionClass $cls */ |
82 | 82 | $cls = collect($method->getParameters()) |
83 | - ->reduce(function ($carry, $param) use ($method) { |
|
83 | + ->reduce(function($carry, $param) use ($method) { |
|
84 | 84 | if (!$param->getType()) { |
85 | 85 | return $carry; |
86 | 86 | } |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | protected function getBodyParametersFromDocBlock(array $tags) |
115 | 115 | { |
116 | 116 | $parameters = collect($tags) |
117 | - ->filter(function ($tag) { |
|
117 | + ->filter(function($tag) { |
|
118 | 118 | return $tag instanceof Tag && $tag->getName() === 'bodyParam'; |
119 | 119 | }) |
120 | - ->mapWithKeys(function ($tag) { |
|
120 | + ->mapWithKeys(function($tag) { |
|
121 | 121 | preg_match('/(.+?)\s+(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content); |
122 | 122 | if (empty($content)) { |
123 | 123 | // this means only name and type were supplied |
@@ -152,10 +152,10 @@ discard block |
||
152 | 152 | protected function getQueryParametersFromDocBlock(array $tags) |
153 | 153 | { |
154 | 154 | $parameters = collect($tags) |
155 | - ->filter(function ($tag) { |
|
155 | + ->filter(function($tag) { |
|
156 | 156 | return $tag instanceof Tag && $tag->getName() === 'queryParam'; |
157 | 157 | }) |
158 | - ->mapWithKeys(function ($tag) { |
|
158 | + ->mapWithKeys(function($tag) { |
|
159 | 159 | preg_match('/(.+?)\s+(required\s+)?(.*)/', $tag->getContent(), $content); |
160 | 160 | if (empty($content)) { |
161 | 161 | // this means only name was supplied |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | protected function getAuthStatusFromDocBlock(array $tags) |
194 | 194 | { |
195 | 195 | $authTag = collect($tags) |
196 | - ->first(function ($tag) { |
|
196 | + ->first(function($tag) { |
|
197 | 197 | return $tag instanceof Tag && strtolower($tag->getName()) === 'authenticated'; |
198 | 198 | }); |
199 | 199 | |
@@ -264,25 +264,25 @@ discard block |
||
264 | 264 | { |
265 | 265 | $faker = Factory::create(); |
266 | 266 | $fakes = [ |
267 | - 'integer' => function () { |
|
267 | + 'integer' => function() { |
|
268 | 268 | return rand(1, 20); |
269 | 269 | }, |
270 | - 'number' => function () use ($faker) { |
|
270 | + 'number' => function() use ($faker) { |
|
271 | 271 | return $faker->randomFloat(); |
272 | 272 | }, |
273 | - 'float' => function () use ($faker) { |
|
273 | + 'float' => function() use ($faker) { |
|
274 | 274 | return $faker->randomFloat(); |
275 | 275 | }, |
276 | - 'boolean' => function () use ($faker) { |
|
276 | + 'boolean' => function() use ($faker) { |
|
277 | 277 | return $faker->boolean(); |
278 | 278 | }, |
279 | - 'string' => function () use ($faker) { |
|
279 | + 'string' => function() use ($faker) { |
|
280 | 280 | return str_random(); |
281 | 281 | }, |
282 | - 'array' => function () { |
|
282 | + 'array' => function() { |
|
283 | 283 | return []; |
284 | 284 | }, |
285 | - 'object' => function () { |
|
285 | + 'object' => function() { |
|
286 | 286 | return new \stdClass; |
287 | 287 | }, |
288 | 288 | ]; |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | |
51 | 51 | private function getAllRoutes(bool $usingDingoRouter, array $versions = []) |
52 | 52 | { |
53 | - if (! $usingDingoRouter) { |
|
53 | + if (!$usingDingoRouter) { |
|
54 | 54 | return RouteFacade::getRoutes(); |
55 | 55 | } |
56 | 56 | |
57 | 57 | $allRouteCollections = app(\Dingo\Api\Routing\Router::class)->getRoutes(); |
58 | 58 | |
59 | 59 | return collect($allRouteCollections) |
60 | - ->flatMap(function (RouteCollection $collection) { |
|
60 | + ->flatMap(function(RouteCollection $collection) { |
|
61 | 61 | return $collection->getRoutes(); |
62 | 62 | })->toArray(); |
63 | 63 | } |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | private function shouldIncludeRoute(Route $route, array $routeRule, array $mustIncludes, bool $usingDingoRouter) |
66 | 66 | { |
67 | 67 | $matchesVersion = $usingDingoRouter |
68 | - ? ! empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
68 | + ? !empty(array_intersect($route->versions(), $routeRule['match']['versions'] ?? [])) |
|
69 | 69 | : true; |
70 | 70 | |
71 | 71 | return str_is($mustIncludes, $route->getName()) |
@@ -48,8 +48,8 @@ |
||
48 | 48 | /** @var Response[]|null $response */ |
49 | 49 | $responses = $strategy($this->route, $tags, $routeProps); |
50 | 50 | |
51 | - if (! is_null($responses)) { |
|
52 | - return array_map(function (Response $response) { |
|
51 | + if (!is_null($responses)) { |
|
52 | + return array_map(function(Response $response) { |
|
53 | 53 | return ['status' => $response->getStatusCode(), 'content' => $this->getResponseContent($response)]; |
54 | 54 | }, $responses); |
55 | 55 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | protected function getDocBlockResponses(array $tags) |
34 | 34 | { |
35 | 35 | $responseTags = array_values( |
36 | - array_filter($tags, function ($tag) { |
|
36 | + array_filter($tags, function($tag) { |
|
37 | 37 | return $tag instanceof Tag && strtolower($tag->getName()) === 'response'; |
38 | 38 | }) |
39 | 39 | ); |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | return; |
43 | 43 | } |
44 | 44 | |
45 | - return array_map(function (Tag $responseTag) { |
|
45 | + return array_map(function(Tag $responseTag) { |
|
46 | 46 | preg_match('/^(\d{3})?\s?([\s\S]*)$/', $responseTag->getContent(), $result); |
47 | 47 | |
48 | 48 | $status = $result[1] ?: 200; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | { |
35 | 35 | // avoid "holes" in the keys of the filtered array, by using array_values on the filtered array |
36 | 36 | $responseFileTags = array_values( |
37 | - array_filter($tags, function ($tag) { |
|
37 | + array_filter($tags, function($tag) { |
|
38 | 38 | return $tag instanceof Tag && strtolower($tag->getName()) === 'responsefile'; |
39 | 39 | }) |
40 | 40 | ); |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | return; |
44 | 44 | } |
45 | 45 | |
46 | - return array_map(function (Tag $responseFileTag) { |
|
46 | + return array_map(function(Tag $responseFileTag) { |
|
47 | 47 | preg_match('/^(\d{3})?\s?([\S]*[\s]*?)(\{.*\})?$/', $responseFileTag->getContent(), $result); |
48 | 48 | $status = $result[1] ?: 200; |
49 | 49 | $content = $result[2] ? file_get_contents(storage_path(trim($result[2])), true) : '{}'; |
50 | - $json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; |
|
50 | + $json = !empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}'; |
|
51 | 51 | $merged = array_merge(json_decode($content, true), json_decode($json, true)); |
52 | 52 | |
53 | 53 | return new JsonResponse($merged, (int) $status); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | $fractal = new Manager(); |
49 | 49 | |
50 | - if (! is_null(config('apidoc.fractal.serializer'))) { |
|
50 | + if (!is_null(config('apidoc.fractal.serializer'))) { |
|
51 | 51 | $fractal->setSerializer(app(config('apidoc.fractal.serializer'))); |
52 | 52 | } |
53 | 53 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | */ |
80 | 80 | private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod) |
81 | 81 | { |
82 | - $modelTag = array_first(array_filter($tags, function ($tag) { |
|
82 | + $modelTag = array_first(array_filter($tags, function($tag) { |
|
83 | 83 | return ($tag instanceof Tag) && strtolower($tag->getName()) == 'transformermodel'; |
84 | 84 | })); |
85 | 85 | |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | $type = $modelTag->getContent(); |
89 | 89 | } else { |
90 | 90 | $parameter = array_first($transformerMethod->getParameters()); |
91 | - if ($parameter->hasType() && ! $parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) { |
|
91 | + if ($parameter->hasType() && !$parameter->getType()->isBuiltin() && class_exists((string) $parameter->getType())) { |
|
92 | 92 | // ladies and gentlemen, we have a type! |
93 | 93 | $type = (string) $parameter->getType(); |
94 | 94 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | private function getTransformerTag(array $tags) |
134 | 134 | { |
135 | 135 | $transFormerTags = array_values( |
136 | - array_filter($tags, function ($tag) { |
|
136 | + array_filter($tags, function($tag) { |
|
137 | 137 | return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['transformer', 'transformercollection']); |
138 | 138 | }) |
139 | 139 | ); |
@@ -27,16 +27,16 @@ discard block |
||
27 | 27 | $collection = [ |
28 | 28 | 'variables' => [], |
29 | 29 | 'info' => [ |
30 | - 'name' => config('apidoc.postman.name') ?: config('app.name').' API', |
|
30 | + 'name' => config('apidoc.postman.name') ?: config('app.name') . ' API', |
|
31 | 31 | '_postman_id' => Uuid::uuid4()->toString(), |
32 | 32 | 'description' => config('apidoc.postman.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 | $mode = $route['methods'][0] === 'PUT' ? 'urlencoded' : 'formdata'; |
41 | 41 | |
42 | 42 | return [ |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | 'method' => $route['methods'][0], |
47 | 47 | 'body' => [ |
48 | 48 | 'mode' => $mode, |
49 | - $mode => collect($route['bodyParameters'])->map(function ($parameter, $key) { |
|
49 | + $mode => collect($route['bodyParameters'])->map(function($parameter, $key) { |
|
50 | 50 | return [ |
51 | 51 | 'key' => $key, |
52 | 52 | 'value' => isset($parameter['value']) ? $parameter['value'] : '', |