SeyZ / jsonapi-serializer

A Node.js framework agnostic library for (de)serializing your data to JSON API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Serialize pluralType not working for relationships

ajmathews opened this issue · comments

My object has a child relationship. The pluralizeType doesn't seem to be working on it. I require the type to be singular. For example,

  test = {
      name: 'this is the name',
      description: 'this is the desc',
      kids: [
        { id: 20 },
        { id: 22 },
        { id: 24 }
      ]
    };
    
    const roleSerializer = new Serializer('parent',
      {
        attributes: ['name', 'description', 'kids'],
        pluralizeType: false,
        kids: {
          ref: 'id',
          pluralizeType: false
        }
      }
    );
    const body = roleSerializer.serialize(test);

The response I am getting is as below,

image

I expect type: "kids" to be type: "kid". Can some one suggest as to what I might be doing wrong?
Thanks

I looked at the code and it seems you guys don't make it singular and only the reverse. Also read up on the issue #12 . Wondering whether this is a feature that you guys see as useful?

Pull Request - #166