I have an doctrine entity Tag defined in xml file like:
<?xml version="1.0" encoding="utf-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="App\Entity\Tag" table="`tag`">
<id name="id" type="bigint" column="id">
<generator strategy="SEQUENCE"/>
<sequence-generator sequence-name="tag_id_seq" allocation-size="1" initial-value="1"/>
</id>
<field name="name" type="string" column="name" length="255" nullable="true">
<options>
<option name="fixed"/>
</options>
</field>
<field name="slug" type="string" column="required" nullable="false">
</field>
</entity>
</doctrine-mapping>
I want to use slug as identifier not an id and I get an error when returning the collection:
No identifier defined in "App\Entity\Tag". You should add # [\ApiPlatform\Core\Annotation\ApiProperty(identifier: true)]" on the property identifying the resource.
Where it should be added? I have a problem of where it should be defined as I can not find any example with xml files
Also, found THIS.