cerebris / jsonapi-resources

A resource-focused Rails library for developing JSON:API compliant servers.
http://jsonapi-resources.com
MIT License
2.32k stars 533 forks source link

Fix empty relationships on included resources #1372

Closed JamesGlover closed 3 years ago

JamesGlover commented 3 years ago

Fixes #1371

JSONAPI::ResourceTree#load_included was failing to correctly populate the resource fragments of included resources, such that the include_related parameter was null. This was resulting in the relationships object lacking a data attribute for nil or empty resources.

The JSON-API specification states that a null or empty array should be returned in these circumstances: https://jsonapi.org/format/#document-resource-object-linkage

The underlying issue appears to be the use of include_related rather than the symbol :include_related when initializing nested resource fragments.

All Submissions:

New Feature Submissions:

Bug fixes and Changes to Core Features:

Test Plan:

Reviewer Checklist:

lgebhardt commented 3 years ago

@JamesGlover Thanks!