Selaa lähdekoodia

Apply configuration to route groups

shalvah 6 vuotta sitten
vanhempi
commit
2847da19b0

+ 6 - 9
config/apidoc.php

@@ -79,15 +79,12 @@ return [
              * Specify rules to be applied to all the routes in this group when generating documentation
              */
             'apply' => [
-                'requests' => [
-
-                    /*
-                     * Specify headers to be added to the example requests
-                     */
-                    'headers' => [
-                        // 'Authorization' => 'Bearer: {token}',
-                        // 'Api-Version' => 'v2',
-                    ],
+                /*
+                 * Specify headers to be added to the example requests
+                 */
+                'headers' => [
+                    // 'Authorization' => 'Bearer: {token}',
+                    // 'Api-Version' => 'v2',
                 ],
             ],
         ],

+ 1 - 2
src/Commands/GenerateDocumentation.php

@@ -188,10 +188,9 @@ class GenerateDocumentation extends Command
         $parsedRoutes = [];
         foreach ($routes as $routeItem) {
             $route = $routeItem['route'];
-            $apply = $routeItem['apply'];
             /** @var Route $route */
                 if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
-                    $parsedRoutes[] = $generator->processRoute($route, $apply);
+                    $parsedRoutes[] = $generator->processRoute($route) + $routeItem['apply'];
                     $this->info('Processed route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));
                 } else {
                     $this->warn('Skipping route: ['.implode(',', $generator->getMethods($route)).'] '.$generator->getUri($route));

+ 1 - 1
src/Generators/AbstractGenerator.php

@@ -49,7 +49,7 @@ abstract class AbstractGenerator
      *
      * @return array
      */
-    public function processRoute($route, $apply = [])
+    public function processRoute($route)
     {
         $routeAction = $route->getAction();
         $routeGroup = $this->getRouteGroup($routeAction['uses']);