8000 Tree : use IRI instead of normalization context · Issue #1130 · api-platform/core · GitHub
[go: up one dir, main page]

8000
Skip to content
Tree : use IRI instead of normalization context #1130
@pierre-H

Description

@pierre-H

Hello !

I've got an entity with a tree :

/**
 * @ApiResource(
 *     itemOperations={
 *          "get"={"method"="GET", "normalization_context"={"groups"={"read"}}},
 *     }
 *  )
 */
class Comment {
    /**
     * @var string
     * @Groups({"read"})
     */
    private $title;

    /**
     * @var Comment
     * @Groups({"read"})
     */
    private $parent;
}

I'd like to have the IRI parent, not the content.
The problem here is that I get :

{
    "title": "My first post",
    "parent": {
        "title": "My second post"
    }
}

instead of :

{
    "title": "My first post",
    "parent": "/posts/2"
}

I know that there is the @MaxDepth annotation, but it doesn't generate IRI. Is there another solution ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0