Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relationships should not require a data attribute. #34

Open
nerdyworm opened this issue Jun 21, 2017 · 3 comments
Open

Relationships should not require a data attribute. #34

nerdyworm opened this issue Jun 21, 2017 · 3 comments

Comments

@nerdyworm
Copy link

I'm having trouble with the following jsonapi document.

{
  "included": [
    {
      "type": "org",
      "relationships": {
        "members": {
          "links": {
            "related": "/api/orgs/1/members"
          }
        }
      }
    }
  ]
}

Decoding fails because some of the relationships do not contain a data attribute. I'm not entirely sure that this is "valid" json-api, but it seems to work with other json-api libraries.

@noahzgordon
Copy link
Owner

According to the spec, the relationships must contain at least one of data, links or meta. That means the above is a valid JSON API document. If it's failing to parse, I'd consider it a bug.

@nerdyworm
Copy link
Author

@mbaltaks
Copy link

I'm seeing a similar issue, where the relationships object contains an object with "data": null - which according to http://jsonapi.org/format/#document-resource-object-linkage seems to be valid (and this is generated by Django REST Framework with a JSON API module). I'm slowly working through a patch, but it's quite fundamental I think, because of

{ data : OneOrMany ResourceIdentifier

Data in a relationship can be null, so I think data : OneOrMany ResourceIdentifier has to change to perhaps data : Maybe OneOrMany ResourceIdentifier, which then has knock-on effects. If there is a better way to model the data (I'm very very new to Elm) please let me know.

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

No branches or pull requests

3 participants