jasminb / jsonapi-converter

JSONAPI-Converter is a Java/Android library that provides support for working with JSONAPI spec
Apache License 2.0
272 stars 81 forks source link

@Relationship is not being deserialized #248

Closed scotzark closed 3 years ago

scotzark commented 3 years ago

Hi-

I have a number of relationship links in a JSON object that work fine, but I am struggling to make one of them work. I am able to follow that link directly and have it de-serialize using the same object I am using in my @Relaionship so I am confused as to why it won't pull it in automatically using the @Relationship annotation. The only difference I see with this particular relationship is that the name is:

@Relationship("marinaHeroPhotos")

but the URL is not plural:

related: "https://[xxxx.xxx.xxxx.xxx]/marinaHeroPhoto"

All other working links have the name matching exactly between the endpoint and the @Relationship name.

Thanks in advance for your help. This is baffling to me!

scotzark commented 3 years ago

Hi I have some updated information on this. It might be that it is my lack of knowledge, but what I found out is that the objects that are not deserializing do not have the relationships field. What I have below works, but the resources that do not are the ones that don't include the relationships field. Can those still be de-serialized automatically?

{ "id": "496", "type": "marinaPhotos", "attributes": { "imgixHost": "tdapishmarinas.imgix.net", "path": "zwt1opgl138qon5hfp0uklw36vv5", "alt": null, "position": 12 }, "relationships": { "marina": { "data": { "type": "marinas", "id": "60" } } } }

jasminb commented 3 years ago

Hello @scotzark,

I'm not sure I understand your problem from the example above. There is a mechanism that allows relationships links resolution, please check testResolverTyped in the ResourceConverterTest.