-
Notifications
You must be signed in to change notification settings - Fork 45
Modify 500 code error response page #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{{ $message }} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -30,7 +30,7 @@ public function saveData(): void | |||||
public function getDocumentation(): array | ||||||
{ | ||||||
if (!file_exists($this->prodFilePath)) { | ||||||
throw new FileNotFoundException(); | ||||||
throw new FileNotFoundException("Documentation file not found :{$this->prodFilePath}"); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's move error message to the exception and just pass the path as arg
Suggested change
|
||||||
} | ||||||
|
||||||
$fileContent = file_get_contents($this->prodFilePath); | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -138,7 +138,21 @@ protected function generateEmptyData(): array | |||||
throw new EmptyContactEmailException(); | ||||||
} | ||||||
|
||||||
$data = [ | ||||||
$data = $this->generateBaseDataObject(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure we need to make this change, could you please revert it? |
||||||
$data['info'] = $this->prepareInfo($this->config['info']); | ||||||
|
||||||
$securityDefinitions = $this->generateSecurityDefinition(); | ||||||
|
||||||
if (!empty($securityDefinitions)) { | ||||||
$data['securityDefinitions'] = $securityDefinitions; | ||||||
} | ||||||
|
||||||
return $data; | ||||||
} | ||||||
|
||||||
protected function generateBaseDataObject(): array | ||||||
{ | ||||||
return [ | ||||||
'openapi' => self::OPEN_API_VERSION, | ||||||
'servers' => [ | ||||||
['url' => URL::query($this->config['basePath'])], | ||||||
|
@@ -147,16 +161,7 @@ protected function generateEmptyData(): array | |||||
'components' => [ | ||||||
'schemas' => $this->config['definitions'], | ||||||
], | ||||||
'info' => $this->prepareInfo($this->config['info']) | ||||||
]; | ||||||
|
||||||
$securityDefinitions = $this->generateSecurityDefinition(); | ||||||
|
||||||
if (!empty($securityDefinitions)) { | ||||||
$data['securityDefinitions'] = $securityDefinitions; | ||||||
} | ||||||
|
||||||
return $data; | ||||||
} | ||||||
|
||||||
protected function generateSecurityDefinition(): ?array | ||||||
|
@@ -804,9 +809,19 @@ public function saveProductionData() | |||||
|
||||||
public function getDocFileContent() | ||||||
{ | ||||||
$documentation = $this->driver->getDocumentation(); | ||||||
try { | ||||||
$documentation = $this->driver->getDocumentation(); | ||||||
|
||||||
$this->openAPIValidator->validate($documentation); | ||||||
} catch (\Exception $exception) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
$data = $this->generateBaseDataObject(); | ||||||
|
||||||
$this->openAPIValidator->validate($documentation); | ||||||
$this->config['info'] = Arr::set($this->config, 'info.description', Arr::get($this->config, 'defaults.error')); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's pass the description view as arg, it would be better to redefine the config field |
||||||
|
||||||
$data['info'] = $this->prepareInfo($this->config['info'], ['message' => $exception->getMessage()]); | ||||||
|
||||||
return $data; | ||||||
} | ||||||
|
||||||
$additionalDocs = config('auto-doc.additional_paths', []); | ||||||
|
||||||
|
@@ -931,7 +946,7 @@ protected function getDefaultValueByType($type) | |||||
return $values[$type]; | ||||||
} | ||||||
|
||||||
protected function prepareInfo(array $info): array | ||||||
protected function prepareInfo(array $info, array $descriptionData = []): array | ||||||
{ | ||||||
if (empty($info)) { | ||||||
return $info; | ||||||
|
@@ -948,7 +963,7 @@ protected function prepareInfo(array $info): array | |||||
} | ||||||
|
||||||
if (!empty($info['description'])) { | ||||||
$info['description'] = view($info['description'])->render(); | ||||||
$info['description'] = view($info['description'], $descriptionData)->render(); | ||||||
} | ||||||
|
||||||
return $info; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's rename file to
error.blade.php
, need to unlink logic from the swagger usage only