Skip to content

Relationship validation issue #6

@X-Coder264

Description

@X-Coder264

Due to https://github.com/undabot/json-api-symfony/blob/v2.2.2/src/Service/Resource/Validation/ResourceValidator.php#L91 I have to send all defined relationships when creating a resource.

Let's say for example that I have user and posts resources and a one to many relationship is defined between user and posts. Sending this payload (which is perfectly valid according to the spec) results in a validation error (which shouldn't happen).

{
  "data": {
    "type": "users",
    "attributes": {
      "foo": "bar"
    }
  }
}
{
  "errors": [
    {
      "title": "This field is missing.",
      "source": {
        "pointer": "/data/relationships/posts"
      }
    }
  ]
}

So I have to send this instead:

{
  "data": {
    "type": "users",
    "attributes": {
      "foo": "bar"
    },
    "relationships": {
      "posts": {
        "data": []
      }
    }
  }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions