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

Including Resources should be by name not type #37

Open
brainwipe opened this issue Jan 19, 2017 · 0 comments
Open

Including Resources should be by name not type #37

brainwipe opened this issue Jan 19, 2017 · 0 comments
Labels

Comments

@brainwipe
Copy link
Owner

Found in #35, when including a resource, it should be the relationship name that is used and not the type. Using the json:api example of blog/author:

GET /articles?include=author

{
  "data": [{
    "type": "articles",
    "id": "1",
    "attributes": {
      "title": "JSON API paints my bikeshed!"
    },
    "links": {
      "self": "http://example.com/articles/1"
    },
    "relationships": {
      "author": {
        "links": {
          "self": "http://example.com/articles/1/relationships/author",
          "related": "http://example.com/articles/1/author"
        },
        "data": { "type": "people", "id": "9" }
      },
    }
  }],
  "included": [{
    "type": "people",
    "id": "9",
    "attributes": {
      "first-name": "Dan",
      "last-name": "Gebhardt",
      "twitter": "dgeb"
    },
    "links": {
      "self": "http://example.com/people/9"
    }
  }
}

In ResourceMapping.cs the line:

var relationship = currentMapping.Relationships.SingleOrDefault(x => x.RelatedBaseResourceType == part);

Should be checking against a resource name not the underlying type.

@brainwipe brainwipe added the bug label Jan 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant