如何在 swagger yii2 中向参数添加数组?
How do I add an array to Parameter in swagger yii2?
如何在 swagger 请求中将此类参数的描述添加到正文中 (yii2
)。
作曲家要求
"yii2mod/yii2-swagger": "*"
我尝试使用 swagger
在 api 中编写一个方法
他就是这样 return:
{
"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数组?
In swagger page
数组 属性 是使用 type="array"
和 @SWG\Items
定义的:
* @SWG\Property(
* property="charsName",
* type="array",
* @SWG\Items(type="string"),
* example={"1","2","3"}
* )
如何在 swagger 请求中将此类参数的描述添加到正文中 (yii2
)。
作曲家要求
"yii2mod/yii2-swagger": "*"
我尝试使用 swagger
在 api 中编写一个方法他就是这样 return:
{
"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数组?
In swagger page
数组 属性 是使用 type="array"
和 @SWG\Items
定义的:
* @SWG\Property(
* property="charsName",
* type="array",
* @SWG\Items(type="string"),
* example={"1","2","3"}
* )