Skip to content

Commit 771ab73

Browse files
authored
Merge pull request #729 from BenjaminRosell/master
Adding Laravel Vapor Support - Fixes #716
2 parents 181a3af + 92ecf51 commit 771ab73

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

config/apidoc.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
*/
3838
'router' => 'laravel',
3939

40+
/*
41+
* The storage to be used when generating assets.
42+
* By default, uses 'local'. If you are using Laravel Vapor, please use S3 and make sure
43+
* the correct bucket is correctly configured in the .env file
44+
*/
45+
'storage' => 'local',
46+
4047
/*
4148
* The base URL to be used in examples and the Postman collection.
4249
* By default, this will be the value of config('app.url').

phpstan.neon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ parameters:
1111
- '#(.*)NunoMaduro\\Collision(.*)#'
1212
- '#Instantiated class Whoops\\Exception\\Inspector not found\.#'
1313
- '#.+Dingo.+#'
14+
- '#Call to an undefined method Illuminate\\Contracts\\Filesystem\\Filesystem::url()#'

src/Http/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public function html()
1919
public function json()
2020
{
2121
return response()->json(
22-
json_decode(Storage::disk('local')->get('apidoc/collection.json'))
22+
json_decode(Storage::disk(config('apidoc.storage'))->get('apidoc/collection.json'))
2323
);
2424
}
2525
}

src/Writing/Writer.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,13 @@ protected function writePostmanCollection(Collection $parsedRoutes): void
206206
$collectionPath = "{$this->outputPath}/collection.json";
207207
file_put_contents($collectionPath, $collection);
208208
} else {
209-
Storage::disk('local')->put('apidoc/collection.json', $collection);
210-
$collectionPath = 'storage/app/apidoc/collection.json';
209+
$storageInstance = Storage::disk($this->config->get('storage'));
210+
$storageInstance->put('apidoc/collection.json', $collection, 'public');
211+
if ($this->config->get('storage') == 'local') {
212+
$collectionPath = 'storage/app/apidoc/collection.json';
213+
} else {
214+
$collectionPath = $storageInstance->url('collection.json');
215+
}
211216
}
212217

213218
$this->output->info("Wrote Postman collection to: {$collectionPath}");
@@ -280,8 +285,8 @@ protected function moveOutputFromSourceFolderToTargetFolder(): void
280285
rename("{$this->sourceOutputPath}/index.html", "$this->outputPath/index.blade.php");
281286
$contents = file_get_contents("$this->outputPath/index.blade.php");
282287
//
283-
$contents = str_replace('href="css/style.css"', 'href="/docs/css/style.css"', $contents);
284-
$contents = str_replace('src="js/all.js"', 'src="/docs/js/all.js"', $contents);
288+
$contents = str_replace('href="css/style.css"', 'href="{{ asset(\'/docs/css/style.css\') }}"', $contents);
289+
$contents = str_replace('src="js/all.js"', 'src="{{ asset(\'/docs/js/all.js\') }}"', $contents);
285290
$contents = str_replace('src="images/', 'src="/docs/images/', $contents);
286291
$contents = preg_replace('#href="https?://.+?/docs/collection.json"#', 'href="{{ route("apidoc.json") }}"', $contents);
287292
file_put_contents("$this->outputPath/index.blade.php", $contents);

0 commit comments

Comments
 (0)