Skip to content

Commit dee3246

Browse files
committed
refactor: display throwable errors too
1 parent ba6dcc9 commit dee3246

File tree

5 files changed

+410
-5
lines changed

5 files changed

+410
-5
lines changed

resources/views/error.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{ $message }}
1+
### **{{ $message }}**

src/Services/SwaggerService.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
use RonasIT\AutoDoc\Traits\GetDependenciesTrait;
2424
use RonasIT\AutoDoc\Validators\SwaggerSpecValidator;
2525
use Symfony\Component\HttpFoundation\Response;
26-
use Exception;
26+
use Throwable;
2727

2828
/**
2929
* @property SwaggerDriverContract $driver
@@ -831,7 +831,7 @@ public function getDocFileContent()
831831
$documentation = $this->driver->getDocumentation();
832832

833833
$this->openAPIValidator->validate($documentation);
834-
} catch (Exception $exception) {
834+
} catch (Throwable $exception) {
835835
return $this->generateEmptyData($this->config['defaults']['error'], ['message' => $exception->getMessage()]);
836836
}
837837

@@ -973,7 +973,7 @@ protected function prepareInfo(?string $view = null, array $viewData = [], array
973973
if (!empty($view)) {
974974
$info['description'] = view($view, $viewData)->render();
975975
}
976-
976+
977977
return array_merge($this->config['info'], $info);
978978
}
979979

tests/SwaggerServiceTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,10 @@ public static function getConstructorInvalidTmpData(): array
222222
'tmpDoc' => 'documentation/invalid_format__response__invalid_items',
223223
'fixture' => 'invalid_format_response_invalid_items.html',
224224
],
225+
[
226+
'tmpDoc' => 'documentation/tmp_data_incorrect_documentation_structure_request',
227+
'fixture' => 'invalid_format_incorrect_documentation_structure_request.html',
228+
],
225229
];
226230
}
227231

@@ -234,7 +238,7 @@ public function testGetDocFileContentInvalidTmpData(
234238

235239
$content = app(SwaggerService::class)->getDocFileContent();
236240

237-
$this->assertEqualsFixture($fixture, $content['info']['description']);
241+
$this->assertStringContainsString($this->getFixture($fixture), $content['info']['description']);
238242
}
239243

240244
public function testEmptyContactEmail()

0 commit comments

Comments
 (0)