BlairAllegroTech / js-data-jsonapi

JsonApi Adapter for js-data
MIT License
15 stars 5 forks source link

Empty ID is Invalid JSONAPI #5

Closed rgant closed 8 years ago

rgant commented 8 years ago

According to my understanding of the JSON API spec, the id member of a resource object must be a string that when combined with the type member is a unique identity for the resource.

Additionally when creating a resource the id is not a required member. But may be included to to create a resource using Client Generated IDs. However in that case the id should be a "properly generated and formatted UUID".

This library defaults to an empty string for a missing id member. I don't think that that conforms to the standard because it is neither a unique identity nor a UUID.

I think this is the function in the code that causes an empty string id to be added to the posts. The comment for that line "JsonApi id is always a string,it can be empty for a new unstored object!" but I think that is not a correct reading of the JSON API spec.

In my opinion if the id is missing then it should not be serialized into the request data.

BlairAllegroTech commented 8 years ago

I agree @rgant i think if the Id is not set it should not be serialized. I'll look into fixing this thanks

rgant commented 8 years ago

@BlairAllegroTech Thanks! That was a bunch of effort on your part and I really appreciate it.

BlairAllegroTech commented 8 years ago

@rgant Well i appreciate the feedback. Its easy to miss some of the finer details the more of these we can identify and fix the better!!