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

JSON API conformity #15

Closed
ghost opened this issue Jun 13, 2018 · 3 comments
Closed

JSON API conformity #15

ghost opened this issue Jun 13, 2018 · 3 comments

Comments

@ghost
Copy link

ghost commented Jun 13, 2018

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

@cosullivan
Copy link
Owner

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.

@ghost
Copy link
Author

ghost commented Jul 4, 2018

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

@hughesjs
Copy link
Collaborator

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

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

2 participants