/**
  * @param RouteCollection $routes
  */
 public static function setRoutes(RouteCollection $routes)
 {
     $routes->group(function (RouteCollection $routes) {
         $routes->tag('photos');
         $routes->get('pets/{id}/photos', 'PhotoController@index')->parameters()->path('id')->int()->required()->returns()->many(PhotoResourceDefinition::class)->summary('Show all photos of a pet');
     });
 }
 /**
  * @param RouteCollection $routes
  */
 public static function setRoutes(RouteCollection $routes)
 {
     $routes->group(function (RouteCollection $routes) {
         $routes->tag('pet');
         $routes->get('pets', 'PetController@index')->returns()->many(PetResourceDefinition::class)->summary('Find pets');
         $routes->get('pets/{id}', 'PetController@show')->parameters()->path('id')->required()->int()->returns()->one(PetResourceDefinition::class)->summary('Show a pet');
     });
 }
 /**
  * Set all routes for this controller
  * @param RouteCollection $routes
  */
 public static function setRoutes(RouteCollection $routes)
 {
     $routes->group(function (RouteCollection $routes) {
         $routes->tag('users');
         $routes->get('users/{id}', 'UserController@show')->parameters()->path('id')->required()->returns()->one(UserResourceDefinition::class)->summary('Return a user object');
         $routes->get('users', 'UserController@index')->returns()->many(UserResourceDefinition::class)->summary('Return all users');
     });
 }
 /**
  * @param RouteCollection $routes
  * @return void
  */
 public function transform(RouteCollection $routes)
 {
     foreach ($routes->getRoutes() as $route) {
         $options = $route->getOptions();
         $route = Route::match([$route->getHttpMethod()], $route->getPath(), $route->getAction());
         if (isset($options['middleware'])) {
             $route->middleware($options['middleware']);
         }
     }
 }
 /**
  * @param $action
  * @return string
  */
 protected function processAction($action)
 {
     if ($this->parent) {
         $action = $this->parent->processAction($action);
     }
     if (isset($this->options['namespace'])) {
         $action = $this->options['namespace'] . '\\' . $action;
     }
     return $action;
 }
<?php

use CatLab\Charon\Collections\RouteCollection;
/*
 * API v1
 */
$routes = new RouteCollection(['prefix' => '/api/v1/', 'namespace' => 'Api\\V1\\Controllers', 'middleware' => ['cors'], 'suffix' => '.{format?}', 'security' => ['oauth2' => ['full']]]);
$routes->group([], function (RouteCollection $routes) {
    // All endpoints have these parameters
    $routes->parameters()->path('format')->enum(['json'])->describe('Output format')->default('json');
    // All endpoints can have these return values
    $routes->returns()->statusCode(403)->describe('Authentication error');
    $routes->returns()->statusCode(404)->describe('Entity not found');
    // Swagger documentation
    $routes->get('description', 'DescriptionController@description')->tag('description');
    // Controllers: oauth middleware is required
    $routes->group(['middleware' => ['oauth']], function (RouteCollection $routes) {
        /*
         * List all controllers
         */
        \App\Http\Api\V1\Controllers\UserController::setRoutes($routes);
        \App\Http\Api\V1\Controllers\PetController::setRoutes($routes);
        \App\Http\Api\V1\Controllers\PhotoController::setRoutes($routes);
    });
});
return $routes;