mirror of
https://github.com/ambieco/scribe.git
synced 2026-04-24 06:04:55 +08:00
Not using config helper inside config file
This commit is contained in:
@@ -17,7 +17,7 @@ return [
|
||||
* The base URL to be used in examples and the Postman collection.
|
||||
* By default, this will be the value of config('app.url').
|
||||
*/
|
||||
'base_url' => config('app.url'),
|
||||
'base_url' => null,
|
||||
|
||||
/*
|
||||
* Generate a Postman collection in addition to HTML docs.
|
||||
|
||||
@@ -42,6 +42,11 @@ class GenerateDocumentation extends Command
|
||||
*/
|
||||
private $docConfig;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $baseUrl;
|
||||
|
||||
public function __construct(RouteMatcher $routeMatcher)
|
||||
{
|
||||
parent::__construct();
|
||||
@@ -60,9 +65,10 @@ class GenerateDocumentation extends Command
|
||||
Flags::$shouldBeVerbose = $this->option('verbose');
|
||||
|
||||
$this->docConfig = new DocumentationConfig(config('apidoc'));
|
||||
$this->baseUrl = $this->docConfig->get('base_url') ?? config('app.url');
|
||||
|
||||
try {
|
||||
URL::forceRootUrl($this->docConfig->get('base_url'));
|
||||
URL::forceRootUrl($this->baseUrl);
|
||||
} catch (\Error $e) {
|
||||
echo "Warning: Couldn't force base url as your version of Lumen doesn't have the forceRootUrl method.\n";
|
||||
echo "You should probably double check URLs in your generated documentation.\n";
|
||||
@@ -111,7 +117,7 @@ class GenerateDocumentation extends Command
|
||||
$route['output'] = (string) view('apidoc::partials.route')
|
||||
->with('route', $route)
|
||||
->with('settings', $settings)
|
||||
->with('baseUrl', $this->docConfig->get('base_url'))
|
||||
->with('baseUrl', $this->baseUrl)
|
||||
->render();
|
||||
|
||||
return $route;
|
||||
@@ -288,7 +294,7 @@ class GenerateDocumentation extends Command
|
||||
*/
|
||||
private function generatePostmanCollection(Collection $routes)
|
||||
{
|
||||
$writer = new CollectionWriter($routes, $this->docConfig->get('base_url'));
|
||||
$writer = new CollectionWriter($routes, $this->baseUrl);
|
||||
|
||||
return $writer->getCollection();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user