Skip to content

Array root documentation #81

@stevelacey

Description

@stevelacey

Maybe I am missing the point... but I don't understand how, why or when the root option works – I am putting it in all sorts of places, on get/post, on namespaces/resources, on CollectionSerializer constructs... and it is never doing what I expect.

I am expecting root: 'users' to make the output:

{
  "users": [
    {
      "name": "steve"
    }
  ]
}

I see past issues that this changed at some point, is there documentation missing around this?

Also I found an issue from years ago that seemed to indicate root: false stopped working on collections at some point – that'd be handy too

Am I right in thinking that a CollectionSerializer with a root option doesn't realise that root until an Adapter handles it or something?

In a bunch of cases in the API I am working on we are returning CollectionSerializer instances from controller action, I've been toying with switching those to a render call – but that doesn't accept any options either

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions