Swagger 发送空的帖子请求

Cad*_*lab 0 php api laravel swagger

我刚刚为 laravel 5.1 (旧项目)设置了 swagger 我为我的项目编写了整个文档,但问题是当我去尝试一下!它发送空请求。当我用邮递员尝试完全相同的事情时,它的工作原理就像它应该的那样。

这是一个例子:

 /**
 * @SWG\Post(
 *     path="/api-routes/verify-report",
 *     consumes={"multipart/form-data"},
 *     description="Verify report",
 *     operationId="verifyReport",
 *     @SWG\Parameter(
 *         description="Application report id",
 *         format="int64",
 *         in="path",
 *         name="report_id",
 *         required=true,
 *         type="string"
 *     ),           
 *     produces={"application/json"},
 *     @SWG\Response(
 *         response="200",
 *         description="successful operation"
 *     ),
 *     summary="Verify report",
 *     tags={
 *         "Verify report"
 *     }
 * )
 * */
public function verifyReport() {

}
Run Code Online (Sandbox Code Playgroud)

我正在使用

"darkaonline/l5-swagger": "~3.0"
Run Code Online (Sandbox Code Playgroud)

小智 5

您只需要像下面这样进行一些更改。

/**
 * @SWG\Post(
 *     path="/api-routes/verify-report",
 *     consumes={"multipart/form-data"},
 *     description="Verify report",
 *     operationId="verifyReport",
 *     consumes={"application/x-www-form-urlencoded"},
 *     produces={"application/json"},
 *     @SWG\Parameter(
 *         description="Application report id",
 *         in="forData",
 *         name="report_id",
 *         required=false,
 *         type="string"
 *     ), 
 *     @SWG\Response(
 *         response="200",
 *         description="successful operation"
 *     ),
 *     summary="Verify report",
 *     tags={
 *         "Verify report"
 *     }
 * )
 * */
public function verifyReport() {

}
Run Code Online (Sandbox Code Playgroud)