我正在尝试使用 NelmioApiDocBundle 发布 json,我显示了 json 示例,但尝试示例中没有显示数组对象属性?我尝试了几种方法来完成此操作,但均未成功,以下是我尝试过的代码。非常感谢任何帮助。
当我尝试为项目添加示例时,它会在数组周围加上引号,因此它不是有效的 json,我必须转义引号,所以它添加斜杠不是我想要的
这是试图在正文中发布的 Json
'{
"postalCode": "75056",
"items":[
{
"code":"3288",
"quantity":"2"
},
{
"code":"3289",
"quantity":"1"
}
]
}'
下面的注释
/**
* @Security("is_granted('IS_AUTHENTICATED_FULLY')")
*
* @Route("/api/shipping/cart/length", name="get_shipping_cart_length", methods={"POST"})
* @SWG\Post(
*
* consumes={"application/json"},
* produces={"application/json"},
* tags={"Shipping"},
* @SWG\Parameter(
* name="Authorization",
* in="header",
* required=true,
* type="string",
* default="Bearer TOKEN",
* description="Authorization"
* ),
* @SWG\Parameter(
* name="body",
* in="body",
* description="json order object",
* type="json",
* required=true,
* paramType="body",
* @SWG\Schema(
* type="object",
* @SWG\Property(
* type="string",
* property="postalCode",
* type="string",
* example="75056",
* required=true
* ),
* @SWG\Property(
* property="items",
* type="array",
* required=true,
* @SWG\Items(
* type="object",
* @SWG\Property(property="code", type="string",required=true ),
* @SWG\Property(property="quantity", type="string",required=true),
* ),
* ),
* )
* ),
* @SWG\Response(
* response=200,
* description="Returns total ground rate",
* ),
* @SWG\Response(
* response=401,
* description="Expired JWT Token | JWT Token not found | Invalid JWT Token",
* )
*
*
* )
*
*/