Skip to content

Commit

Permalink
Apply configuration to route groups
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Oct 11, 2018
1 parent e896710 commit 2847da1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
15 changes: 6 additions & 9 deletions config/apidoc.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,12 @@
* 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',
],
],
],
Expand Down
3 changes: 1 addition & 2 deletions src/Commands/GenerateDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,9 @@ private function processRoutes(AbstractGenerator $generator, array $routes)
$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));
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/AbstractGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getMethods(Route $route)
*
* @return array
*/
public function processRoute($route, $apply = [])
public function processRoute($route)
{
$routeAction = $route->getAction();
$routeGroup = $this->getRouteGroup($routeAction['uses']);
Expand Down

0 comments on commit 2847da1

Please sign in to comment.