api-platform / admin

A beautiful and fully-featured administration interface builder for hypermedia APIs
https://api-platform.com/docs/admin/
MIT License
477 stars 131 forks source link

Subobjects not shown or crash Admin #538

Open ili101 opened 4 months ago

ili101 commented 4 months ago

API Platform version(s) affected: 3.2.16

Description
With readableLink false Collection displayed as links, single is empty:

    #[Groups(groups: ['Main:write'])]
    #[ORM\OneToMany(mappedBy: 'main', targetEntity: Sub::class, orphanRemoval: true, cascade: ['remove', 'persist', 'refresh', 'merge', 'detach'])]
    #[ApiProperty(readableLink: false, writableLink: false)]
    private Collection $subs;

    #[Groups(groups: ['Main:write'])]
    #[ApiProperty(readableLink: false, writableLink: false)]
    #[ORM\ManyToOne(inversedBy: 'mains', cascade: ['remove', 'persist', 'refresh', 'merge', 'detach'])]
    private ?One $one = null;

image

With readableLink true Collection displayed as json:

    #[Groups(groups: ['Main:write'])]
    #[ORM\OneToMany(mappedBy: 'main', targetEntity: Sub::class, orphanRemoval: true, cascade: ['remove', 'persist', 'refresh', 'merge', 'detach'])]
    #[ApiProperty(readableLink: true, writableLink: true)]
    private Collection $subs;

image

With readableLink true Object, Admin crashes:

    #[Groups(groups: ['Main:write'])]
    #[ApiProperty(readableLink: true, writableLink: true)]
    #[ORM\ManyToOne(inversedBy: 'mains', cascade: ['remove', 'persist', 'refresh', 'merge', 'detach'])]
    private ?One $one = null;

image

Unhandled Runtime Error
TypeError: data.map is not a function

Unhandled Runtime Error
Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object.
Check the render method of `CustomError`.

How to reproduce Full example: https://github.com/ili101/api-platform/tree/adminTest