Skip to content

Commit

Permalink
fix(Asset): fixed asset not fount (404)
Browse files Browse the repository at this point in the history
  • Loading branch information
“Gossteer” authored and “Gossteer” committed Nov 1, 2022
1 parent 0b1c3f5 commit 7bb258b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Http/Controllers/SwaggerAssetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ public function index(Request $request)
{
$fileSystem = new Filesystem();
$documentation = $request->offsetGet('documentation');

$asset = $request->offsetGet('asset');
if (! is_array($asset)) {
return abort(404, 'asset is not an array');
}
$asset = implode('.', $asset);

try {
$path = swagger_ui_dist_path($documentation, $asset);
Expand Down
5 changes: 4 additions & 1 deletion src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ function l5_swagger_asset(string $documentation, $asset)

$useAbsolutePath = config('l5-swagger.documentations.'.$documentation.'.paths.use_absolute_path', true);

return route('l5-swagger.'.$documentation.'.asset', $asset, $useAbsolutePath).'?v='.md5_file($file);
return route('l5-swagger.'.$documentation.'.asset', [
'asset' => explode('.', $asset),
'v' => hash_file('md5', $file),
], $useAbsolutePath);
}
}
2 changes: 1 addition & 1 deletion src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
'uses' => '\L5Swagger\Http\Controllers\SwaggerController@docs',
]);

$router->get($config['routes']['docs'].'/asset/{asset}', [
$router->get($config['routes']['docs'].'/formation/asset', [
'as' => 'l5-swagger.'.$name.'.asset',
'middleware' => $config['routes']['middleware']['asset'] ?? [],
'uses' => '\L5Swagger\Http\Controllers\SwaggerAssetController@index',
Expand Down

0 comments on commit 7bb258b

Please sign in to comment.