dseax40600 2019-07-23 15:03
浏览 145

Symfony APi平台在api doc中呈现枚举类型

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

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog