[ 
https://issues.apache.org/jira/browse/CAMEL-26000?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen reassigned CAMEL-26000:
-----------------------------------

    Assignee: Claus Ibsen

> camel-jsonapi - support JSON:API collection documents, whose data is an array
> -----------------------------------------------------------------------------
>
>                 Key: CAMEL-26000
>                 URL: https://issues.apache.org/jira/browse/CAMEL-26000
>             Project: Camel
>          Issue Type: Improvement
>            Reporter: Claus Ibsen
>            Assignee: Claus Ibsen
>            Priority: Minor
>             Fix For: 4.24.0
>
>
> The jsonApi data format reads and writes only documents whose primary data is 
> one resource object: unmarshal calls {{readDocument}} ({{JsonApiDataFormat}}, 
> main 50d17f9c2614, lines 92 and 95), and marshal wraps the body in one 
> {{JSONAPIDocument}} (line 77). A JSON:API collection document, whose {{data}} 
> is an array, is common: for example the answer to GET /articles. It cannot be 
> used:
> * unmarshal fails with {{InvalidJsonApiResourceException: Primary data must 
> be either a single resource object, a single resource identifier object, or 
> null}};
> * marshal of a List of resource objects fails with 
> {{DocumentSerializationException}} ({{ClassCastException: ArrayNode cannot be 
> cast to ObjectNode}}).
> jsonapi-converter has {{readDocumentCollection}} and 
> {{writeDocumentCollection}} for these documents.
> Checked on 4.24.0-SNAPSHOT with {{camel run}}, with a {{@Type("books")}} 
> class:
> * a document with one book: the {{Book}};
> * a document with an array of two books: the exception above;
> * marshal of a List of two {{Book}} objects: the exception above.
> *Proposed change*: read a document whose data is an array with 
> {{readDocumentCollection}}, giving a List, and write a Collection body with 
> {{writeDocumentCollection}}.
> _Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to