Skip to content

Commit

Permalink
removed obsolete property in try catch + fix test name
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Damen committed Mar 30, 2023
1 parent a1a1779 commit b580322
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Http/Controllers/OpenApiJsonController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __invoke(Request $request, string $filename) : JsonResponse
$file = collect(config('swagger-ui.files'))->filter(function ($values) use ($filename, $path) {
return isset($values['versions'][$filename]) && ltrim($values['path'], '/') === $path;
})->firstOrFail();
} catch (ItemNotFoundException $e) {
} catch (ItemNotFoundException) {
return abort(404);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Http/Controllers/SwaggerViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ public function __invoke(Request $request)
$file = collect(config('swagger-ui.files'))->filter(function ($values) use ($request) {
return ltrim($values['path'], '/') === $request->path();
})->firstOrFail();
} catch (ItemNotFoundException $e) {
return response()->json(['error' => 'File not found'], 404);
} catch (ItemNotFoundException) {
return abort(404);
}

return view('swagger-ui::index', ['data' => collect($file)]);
Expand Down
2 changes: 1 addition & 1 deletion tests/OpenApiRouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function it_returns_not_found_response_if_provided_version_does_not_exist
}

/** @test */
public function it_returns_not_found_response_if_provided_file_does_not_exist()
public function it_returns_not_found_response_if_provided_file_does_not_exist_even_when_provided_version_exists()
{
$this->getJson('foo-bar/v1')
->assertStatus(404);
Expand Down

0 comments on commit b580322

Please sign in to comment.