如何向swagger yii2中的参数添加数组?

如何向swagger yii2中的参数添加数组?,yii2,swagger,Yii2,Swagger,如何在swagger(yii2)中的请求中将此类参数的描述添加到正文中 作曲家要求 “yii2mod/yii2大摇大摆”:“* 我尝试使用swagger在api中编写一个方法 这就是他所回报的: { "parent_id":"", "name":"testCategory3", "position":"0", "status":"1", "publish-status":"1", "charsName":["1","2","3"] } 我的描述: /** * @SWG\Put(

如何在swagger(
yii2
)中的请求中将此类参数的描述添加到正文中

作曲家要求

“yii2mod/yii2大摇大摆”:“*

我尝试使用swagger在api中编写一个方法

这就是他所回报的:

{
"parent_id":"",
"name":"testCategory3",
"position":"0",
"status":"1",
"publish-status":"1",
"charsName":["1","2","3"]
}
我的描述:

   /**
     * @SWG\Put(path="/api/createCategory",
     *     tags={"Category"},
     *     summary="Create Category",
     *     @SWG\Parameter(
     *         name="Authorization",
     *         in="header",
     *         description=" ID",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="body",
     *         in="body",
     *         required=true,
     *         @SWG\Schema(
     *             type="object",
     *             @SWG\Property(property="parent_id", type="integer" ),
     *             @SWG\Property(property="status", type="integer" ),
     *             @SWG\Property(property="publish-status", type="integer" ),
     *             @SWG\Property(property="position", type="integer" ),
     *             @SWG\Property(property="name", type="string" ),
     *         )
     *     ),
     *     @SWG\Response(
     *         response = 200,
     *         description = "Ok",
     *         @SWG\Schema(ref = "#/")
     *     ),
     *     @SWG\Response(
     *         response = 400,
     *         description = "Bad Request",
     *         @SWG\Schema(ref = "#/")
     *     ),
     *     @SWG\Response(
     *         response = 404,
     *         description = "Not Found",
     *         @SWG\Schema(ref = "#/")
     *     ),
     *     @SWG\Response(
     *         response = 500,
     *         description = "Internal Server Error"
     *     )
     * )
     */
如何添加charsName数组


使用
type=“array”
@SWG\Items
定义数组属性:

*@SWG\Property(
*property=“charsName”,
*type=“数组”,
*@SWG\Items(type=“string”),
*示例={“1”、“2”、“3”}
*             )

非常感谢。你能告诉我如何将其包装成一个数组吗?当添加到你的
@SWG\Schema
中时,这个注释正好对应于你原来帖子中的
“charsName”:[“1”、“2”、“3”]