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

Handling local identifier ("lid") when creating resource #265

Open maksym-szymczak opened 10 months ago

maksym-szymczak commented 10 months ago

Hello,

I'm writing client for API which requires base resource with included relationship resources during creation. I need to use "lid" to identify those resources in request. Is there any way to handle such case in this library?

Thanks for your help

jasminb commented 10 months ago

Hey @maksym-szymczak can you provide an example of what you are trying to achieve, I'm a bit slow today 😄

maksym-szymczak commented 10 months ago

I want to create request body that will look like this: { "data": { "type": "person", "attributes": { "firstName": "Jonh", "lastName": "Smith" }, "relationships": { "otherPersons": { "data": [ { "lid": "1", "type": "otherPerson" }, { "lid": "2", "type": "otherPerson" } ] } }, "included": [ { "lid": "1", "type": "otherPerson", "attributes": { "firstName": "Joe", "lastName": "Doe" } }, { "lid": "2", "type": "otherPerson", "attributes": { "firstName": "Jane", "lastName": "Doe" } } ] } }

So server can create the base resource (person) and also relationship resources provided as "included" https://jsonapi.org/format/1.1/#document-resource-object-identification

jasminb commented 10 months ago

@maksym-szymczak got it, lib is not in sync with the spec, will add support and let you know here.

maksym-szymczak commented 10 months ago

@jasminb Great, thanks a lot!