Skip to content

Commit

Permalink
Make auto docs routes compatible with Lumen (fixes #206)
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jun 9, 2021
1 parent 69a5211 commit 10bda0e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions routes/lumen.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Knuckles\Scribe\Http\Controller;

$prefix = config('scribe.laravel.docs_url', '/docs');
$middleware = config('scribe.laravel.middleware', []);

$router = app()->router;

$router->group([
'middleware' => $middleware
], function () use ($router, $prefix) {
$router->get($prefix, ['uses' => [Controller::class, 'webpage'], 'as' => 'scribe']);
$router->get("$prefix.postman", ['uses' => [Controller::class, 'postman'], 'as' => 'scribe.postman']);
$router->get("$prefix.openapi", ['uses' => [Controller::class, 'openapi'], 'as' => 'scribe.openapi']);
});
6 changes: 3 additions & 3 deletions src/ScribeServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Knuckles\Scribe\Commands\MakeStrategy;
use Knuckles\Scribe\Matching\RouteMatcher;
use Knuckles\Scribe\Matching\RouteMatcherInterface;
use Knuckles\Scribe\Tools\Utils;

class ScribeServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -56,9 +57,8 @@ protected function bootRoutes()
config('scribe.type', 'static') === 'laravel' &&
config('scribe.laravel.add_routes', false)
) {
$this->loadRoutesFrom(
__DIR__ . '/../routes/laravel.php'
);
$routesPath = Utils::isLumen() ? __DIR__ . '/../routes/lumen.php' : __DIR__ . '/../routes/laravel.php';
$this->loadRoutesFrom($routesPath);
}
}
}

0 comments on commit 10bda0e

Please sign in to comment.