1

I have an API in Symfony Flex, that is documented with use of NelmioApiDocBundle. In Documentation, I want to show, that parentPOSId parameter can be int or null. How can I do it?

This are my controller annotations:

 /**
 *
 * @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)
 *     )
 * )
 *
 */

This is my model:

namespace App\Domain\Port\POSParent;

interface SetPOSParentInterface
{
    public function getPOSId():int;

    public function getParentPOSId():?int;
}
Anna
  • 43
  • 6
  • have you tried a simple `@var int|null`? – LBA Feb 19 '19 at 11:44
  • 1
    Why do you need to show that ? According to me, just setting your parameter as not required is enough. If no value is given by the user, the value of the parameter will be null. – titili Feb 19 '19 at 16:35

0 Answers0