Skip to content

Commit

Permalink
Merge pull request #125 from RonasIT/fix-missed-empty-responses-defin…
Browse files Browse the repository at this point in the history
…itions

fix: missed response definition when the content of response was empty
  • Loading branch information
DenTray authored May 2, 2024
2 parents d42ab6c + 555604e commit 4c3a0c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 2 additions & 6 deletions src/Services/SwaggerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,14 +296,10 @@ protected function markAsDeprecated(array $annotations)

protected function saveResponseSchema(?array $content, string $definition): void
{
if (empty($content)) {
return;
}

$schemaProperties = [];
$schemaType = 'object';

if (array_is_list($content)) {
if (!empty($content) && array_is_list($content)) {
$this->saveListResponseDefinitions($content, $schemaProperties);

$schemaType = 'array';
Expand Down Expand Up @@ -366,7 +362,7 @@ protected function parseResponse($response)

$responseExampleLimitCount = config('auto-doc.response_example_limit_count');

$content = json_decode($response->getContent(), true);
$content = json_decode($response->getContent(), true) ?? [];

if (!empty($responseExampleLimitCount)) {
if (!empty($content['data'])) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
"204": {
"description": "Operation successfully done",
"schema": {
"example": null,
"example": [],
"$ref": "#/definitions/patchUsers{id}204ResponseObject"
}
}
Expand Down Expand Up @@ -141,6 +141,10 @@
"query": null
},
"required": ["query"]
},
"patchUsers{id}204ResponseObject": {
"type": "object",
"properties": []
}
},
"info": {
Expand Down

0 comments on commit 4c3a0c9

Please sign in to comment.