diff --git a/CHANGELOG.md b/CHANGELOG.md index e3c4b0ae..0c5eada3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ #### Changed - Improved and more extensive documentation +### 0.3.5 - 2015-08-19 + +#### Fixed +- The included key is not sent if it is empty + ### 0.3.4 - 2015-08-18 #### Fixed diff --git a/src/JsonApi/Schema/Included.php b/src/JsonApi/Schema/Included.php index 15730050..1dfb36c5 100644 --- a/src/JsonApi/Schema/Included.php +++ b/src/JsonApi/Schema/Included.php @@ -8,6 +8,14 @@ class Included */ private $included = []; + /** + * @return bool + */ + public function isEmpty() + { + return empty($this->included); + } + /** * @param array $transformedResource * @return $this diff --git a/src/JsonApi/Transformer/AbstractCompoundDocument.php b/src/JsonApi/Transformer/AbstractCompoundDocument.php index 964eac89..dbfe905b 100644 --- a/src/JsonApi/Transformer/AbstractCompoundDocument.php +++ b/src/JsonApi/Transformer/AbstractCompoundDocument.php @@ -130,7 +130,7 @@ protected function transformContent(RequestInterface $request) $content["data"] = $this->data; // Included - if ($this->included !== null) { + if ($this->included->isEmpty() === false) { $content["included"] = $this->included->transform(); }