Skip to content

Commit

Permalink
Merge branch 'non-json-response-files'
Browse files Browse the repository at this point in the history
  • Loading branch information
whizzrd committed May 22, 2021
2 parents 8085086 + 9299066 commit 3279e98
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Extracting/Strategies/Responses/UseResponseFileTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ protected function getFileResponses(array $tags)
}
$status = $result[1] ?: 200;
$content = $result[2] ? file_get_contents($filePath, true) : '{}';
$json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
$merged = array_merge(json_decode($content, true), json_decode($json, true));

try {
$json = ! empty($result[3]) ? str_replace("'", '"', $result[3]) : '{}';
$merged = array_merge(json_decode($content, true), json_decode($json, true));
} catch (\Exception $e) {
$merged = $content;
}

return ['content' => json_encode($merged), 'status' => (int) $status];
}, $responseFileTags);
Expand Down

0 comments on commit 3279e98

Please sign in to comment.