招摇的laravel中的post方法

时间:2018-07-04 07:30:48

标签: laravel swagger

我正在尝试在swagger laravel中实现post方法。我的代码就是这个,并且附有错误的图片。

"/user": {
  "post": {
    "tags": [
      "data"
    ],
    "summary": "add user",
    "description": "",
    "operationId": "user",
    "produces": [
      "application/json"
    ],
    "consumes": [
      "application/x-www-form-urlencoded"
    ],
    "parameters": [
      {
        "name": "subcategory",
        "in": "formData",
        "description": "Subchannel Name",
        "required": true,
        "type": "string"
      },
    ],
    "responses": {
      "200": {
        "description": "user response",
        "schema": {
          "$ref": ""
        }
      }
    },
    "security": [
      {
        "apiKey": [{"api_token":[]}]
      }
    ]
  }
},

 /**
 * @SWG\Post(
 *      path="/api/user",
 *      tags={"User"},
 *      operationId="user",
 *      summary="Add User",
 *      security={{"api_token": {}}},
 *      consumes={"application/x-www-form-urlencoded"},
 *      produces={"application/json"},
 *      @SWG\Parameter(
 *          name="name",
 *          in="formData",
 *          required=true, 
 *          type="string" 
 *      ),
 *      @SWG\Parameter(
 *          name="phone",
 *          in="formData",
 *          required=true, 
 *          type="number" 
 *      ),
 *      @SWG\Response(
 *          response=200,
 *          description="Success"
 *      ),
 */

路线

Route::post('api/user', 'DashboardController@users');

{ 
  "message": "", 
  "exception": "Symfony\\Component\\HttpKernel\\Exception\\HttpException",
  "file": "D:\\xamp\\htdocs\\testApi\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php", 
  "line": 203, 
  "trace": [ 
    { 
      "file": "D:\\xamp\\htdocs\\testApi\\vendor\\laravel\\framework\\src\\Illuminate\\Foundation\\Exceptions\\Handler.php", 
      "line": 175, 
      "function": "prepareException", 
      "class": "Illuminate\\Foundation\\Exceptions\\Handler", 
      "type": "->" 
    }
  ]
}

0 个答案:

没有答案