I am using Api platform to create base endpoints and documentation. For this purpose, I use DTO . One of my entity, which converts to DTO, has an enum type which is based on Myclabs/Enum - in doctrine, it mapped like (smallint).
I want, API platform renders this enum, not like the simple scalar value but like nested object with key-value and label - title
For example:
class Choice
{
/**@var string **/
$name;
/**@var int (can be only 1 or only 2) **/
$measureUnitType;
}
measureUnitType:
class MeasurementUnit extends MyCLabs\Enum\Enum
{
private const METRIC = 1;
private const IMPERIAL = 2;
}
So I want the next output:
{
"name": "testName",
"require": {
"value": 1,
"label": "IMPERIAL"
}
}
I have read this piece of doc but honestly, I didn`t realize how achieve my goal