Skip to content

Commit

Permalink
fix: missed response definition when the content of response was empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Goodmain committed Apr 27, 2024
1 parent ff32d9b commit 555604e
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 555604e

Please sign in to comment.