cosullivan/Hypermedia

JSON API conformity

Closed this issue · 3 comments

Hello,

we wanted to use you client library with our JSON API server implementation and recognized an issue regarding the JSON API conformity.

Using the URL http://hypermedia.cainosullivan.com/v1/posts/1?$prettify=true&$format=jsonapi, the response starts with:

{
  "jsonapi":{
    "version":"1.0"
  }, 
  "data":{
    "type":"posts", 
    "id":1, 
    ...
}

Your server implementation returns a number as "data.id". The JSON API specifies that both "data.type" and "data.id" must be strings:

Identification
Every resource object MUST contain an id member and a type member. The values of the id and type members MUST be strings.

Regards

Jochen

Hi,

Sorry for the delay in the reply. Is your client side model using int's or string's for the ID's?

I will look at putting in an option to correct that according to the spec, however you can obviously force it to be a string by making your ID properties on your models as int's or Guid's.

If you are using the Hypermedia packages on the server too, then you can currently apply a post-process over the JSON prior to it being sent to the client and resolve that yourself for now. Take a look at how this is being used in the sample;
https://github.com/cosullivan/Hypermedia/blob/master/Src/Hypermedia.Sample.WebApi/Services/JsonApiMetadataMediaTypeFormatter.cs

Thanks,
Cain.

Hi Cain,

thank you for the answer. We use both integers and UUIDs. With the JSON API we process both as strings. An option to specify strings as IDs would be very welcome.

Regards,
Jochen

I'm closing this because it's stale and the account that raised it has been deleted, if anyone else has this issue please feel free to reopen