首页 > 解决方案 > 如何设置,该参数值在 nelmio api doc 中可以为空?

问题描述

我在 Symfony Flex 中有一个 API,使用 NelmioApiDocBundle 进行了记录。在文档中,我想显示,该parentPOSId参数可以是 int 或 null。我该怎么做?

这是我的控制器注释:

 /**
 *
 * @FOSRest\Post("/pos/parent")
 *
 * @SWG\Post(
 *     tags={"pos_parent"},
 *     description="set POS parent",
 *     @SWG\Response(
 *       response=200,
 *       description="Parent was set",
 *       examples={
 *          "application/json":{
 *              "POSId":2,
 *              "parentPOSId": 1
 *          }
 *       }
 *     ),
 *
 *     @SWG\Parameter(
 *         name="form",
 *         in="body",
 *         description="Action parameters",
 *         @Model(type=App\Domain\Port\POSParent\SetPOSParentInterface::class)
 *     )
 * )
 *
 */

这是我的模型:

namespace App\Domain\Port\POSParent;

interface SetPOSParentInterface
{
    public function getPOSId():int;

    public function getParentPOSId():?int;
}

标签: phpsymfonyswaggernelmioapidocbundle

解决方案


推荐阅读