Skip to content

attributes type property it is being overridden#4

Description

@tombiasz

First of all I want to say thank you for creating such neat package 馃檱

Unfortunately I found a little bug using it. As it is stated in the title, If data.attributes contains type property (data.attributes.type) it is being overridden by type in data object (data.type)

As is:

const jsonApiNormalize = require('json-api-normalize');

const input = {
    data: {
        type: 'article', // <--
        id: '1',
        attributes: {
            type: 'other type' // <--

            title: 'JSON API paints my bikeshed!',
            body: 'The shortest article. Ever.',
        },
    },
}

jsonApiNormalize(input).get(['type']);
// returns { type:"article" }

To be:
Should return { type:"other type" }

Not sure how this should be resolved, because there might be situation where data.type is also needed. Maybe some special char should be introduced like $ eg $id would be equal to data.id and $type to data.type

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions