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

data and errors MUST NOT coexist #142

Description

@langeuh

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions