Skip to content

Commit 5ce0188

Browse files
authored
Merge pull request #548 from gpressutto5/fix/null-base_url
Not using config helper inside config file
2 parents c4422ce + b3a93de commit 5ce0188

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

config/apidoc.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* The base URL to be used in examples and the Postman collection.
1818
* By default, this will be the value of config('app.url').
1919
*/
20-
'base_url' => config('app.url'),
20+
'base_url' => null,
2121

2222
/*
2323
* Generate a Postman collection in addition to HTML docs.

src/Commands/GenerateDocumentation.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ class GenerateDocumentation extends Command
4242
*/
4343
private $docConfig;
4444

45+
/**
46+
* @var string
47+
*/
48+
private $baseUrl;
49+
4550
public function __construct(RouteMatcher $routeMatcher)
4651
{
4752
parent::__construct();
@@ -60,9 +65,10 @@ public function handle()
6065
Flags::$shouldBeVerbose = $this->option('verbose');
6166

6267
$this->docConfig = new DocumentationConfig(config('apidoc'));
68+
$this->baseUrl = $this->docConfig->get('base_url') ?? config('app.url');
6369

6470
try {
65-
URL::forceRootUrl($this->docConfig->get('base_url'));
71+
URL::forceRootUrl($this->baseUrl);
6672
} catch (\Error $e) {
6773
echo "Warning: Couldn't force base url as your version of Lumen doesn't have the forceRootUrl method.\n";
6874
echo "You should probably double check URLs in your generated documentation.\n";
@@ -111,7 +117,7 @@ private function writeMarkdown($parsedRoutes)
111117
$route['output'] = (string) view('apidoc::partials.route')
112118
->with('route', $route)
113119
->with('settings', $settings)
114-
->with('baseUrl', $this->docConfig->get('base_url'))
120+
->with('baseUrl', $this->baseUrl)
115121
->render();
116122

117123
return $route;
@@ -288,7 +294,7 @@ private function isRouteVisibleForDocumentation($action)
288294
*/
289295
private function generatePostmanCollection(Collection $routes)
290296
{
291-
$writer = new CollectionWriter($routes, $this->docConfig->get('base_url'));
297+
$writer = new CollectionWriter($routes, $this->baseUrl);
292298

293299
return $writer->getCollection();
294300
}

0 commit comments

Comments
 (0)