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

Document collection always throw error while using readCollections #244

Open
PNat01 opened this issue Nov 17, 2020 · 1 comment
Open

Document collection always throw error while using readCollections #244

PNat01 opened this issue Nov 17, 2020 · 1 comment

Comments

@PNat01
Copy link

PNat01 commented Nov 17, 2020

JSONAPIDocument<List> jsonApiDocumentCollection =
converter.readDocumentCollection(data, clazz);

the above code always throws a exception while reading a collection of document. It erros out during validation in this method

It calls ValidationUtils.ensureValidDocument(ObjectMapper mapper, JsonNode resourceNode) which throws an error at the snipped of code
if (!hasData && !hasMeta) {
throw new InvalidJsonApiResourceException();
}

My json has a data array field

sample

{"data":[{"id":"3f33589e-1d1d-46f7-aff8-94be3252a1ea","type":"xxx",...},{"id":"3f33589e-1d1d-46f7-aff8-94be3252a1ea","type":"xxx",...}]}
Please help asap.

Thanks in advance.

@jasminb
Copy link
Owner

jasminb commented Nov 18, 2020

Hello @PNat01,

Did you try debugging the validation logic? Please try to set a break point before validation error is thrown and check if resourceNode has data attribute. Code that does the check is pretty simple and the only obvious reason for the error that you are seeing is that the resourceNode does not have meta nor data nodes.

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