Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

data and errors MUST NOT coexist #142

Open
langeuh opened this issue Mar 7, 2018 · 0 comments
Open

data and errors MUST NOT coexist #142

langeuh opened this issue Mar 7, 2018 · 0 comments

Comments

@langeuh
Copy link

langeuh commented Mar 7, 2018

The members data and errors MUST NOT coexist in the same document.
see http://jsonapi.org/format/#document-top-level

I quickly solved it this way as any exception gets turned in to an error in my code

I extended Tobscure\JsonApi\Document and overwrote the toArray() function

public function toArray()
{
    // The members data and errors MUST NOT coexist in the same document.
    if (!empty($this->errors)) {
        $this->data = null;
        $this->links = null;
    }

    return parent::toArray();
}

Ideally this gets combined with #130

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant