Skip to content

Conversation

@csantero
Copy link
Collaborator

According to the spec, sending a link should look like this:

{
    "posts": {
        "id": "2",
        "title": "How to fry an egg",
        "links": {
            "author": {
                "href": "/users/5"
            }
        }
    }
}

The formatter is currently sending:

{
    "posts": {
        "id": "2",
        "title": "How to fry an egg",
        "links": {
            "author": "/users/5"
        }
    }
}

There is no way for the client to tell that that is a link and not an ID. This PR changes the handling for [SerializeAs(SerializeAsOptions.Link)] to put the link on an href key in an embedded object.

I needed the json minifier helper from #8, so I included it here as a separate commit. I may need to rebase one of these PRs when you merge the other.

@SphtKr
Copy link
Collaborator

SphtKr commented Jan 20, 2015

Crap, you're right...I wonder if the spec changed since I implemented that, but I see what you mean about why it needs to be discernable from an Id.

This will break previous behavior, so it will probably be helpful to go to 0.3.0 when this is put into a release.

@SphtKr
Copy link
Collaborator

SphtKr commented Jan 20, 2015

Got #8 committed, so you should be able to rebase now.

@SphtKr SphtKr added this to the 0.3.0 milestone Jan 20, 2015
@csantero
Copy link
Collaborator Author

All ready to go!

SphtKr added a commit that referenced this pull request Jan 21, 2015
Send link as href in embedded object
@SphtKr SphtKr merged commit 42d717c into JSONAPIdotNET:master Jan 21, 2015
@SphtKr
Copy link
Collaborator

SphtKr commented Jan 21, 2015

Ugh...for future reference, we should watch this issue, which would reverse this change.

@csantero csantero deleted the link-template-href branch January 21, 2015 22:27
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

Successfully merging this pull request may close these issues.

2 participants