yury-dymov / json-api-normalizer

Normalize JSON API data for redux applications
MIT License
576 stars 40 forks source link

Support for object in primary data #18

Closed JannikStreek closed 7 years ago

JannikStreek commented 7 years ago

Hi,

it seems like json-api-normalizer can't handle single objects in the primary data field (if not encapsulated in an array, as the examples in the readme suggest).

According to the json api doc, a single object should also be accepted:

Primary data MUST be either:

a single resource object, a single resource identifier object, or null, for requests that target single resources
an array of resource objects, an array of resource identifier objects, or an empty array ([]), for requests that target resource collections

Backends that follow the specification for single objects (e.g. in the show route of a resource) are now not supported. I am happy to create a pull request if you also think that it should be supported.

JannikStreek commented 7 years ago

...sorry never mind, just went through the code and saw that it is actually already working. Seems like i oversaw the normalized object in the output.