2017-08-23 54 views
1

我已經更新get方法的代碼如下,在swagger中正常工作 。Laravel(發佈,刪除,放)路線在Swagger

任何人都可以給我推薦用於發佈,放置,刪除它的laravel路徑,控制器代碼的swagger代碼。 (正如我提到遵循GET)

路線/ web.php

 Route::group(['prefix' => 'api/'], function() { 
      Route::get('dashboard', '[email protected]'); 
     }); 

DashboardController.php

* Display a listing of the resource. 
* 
* @return \Illuminate\Http\JsonResponse 
* 
* @SWG\Get(
*  path="/api/dashboard", 
*  description="Returns dashboard overview.", 
*  operationId="api.dashboard.index", 
*  produces={"application/json"}, 
*  tags={"dashboard"}, 
*  @SWG\Response(
*   response=200, 
*   description="Dashboard overview." 
* ), 
*  @SWG\Response(
*   response=401, 
*   description="Unauthorized action.", 
* ) 
*) 
*/ 

public function index(Request $request) 
{ 
    return response()->json([ 
     'result' => [ 
      'statistics' => [ 
       'users' => [ 
        'name' => 'Name', 
        'email' => '[email protected]' 
       ] 
      ], 
     ], 
     'message' => '', 
     'type'  => 'success', 
     'status' => 0 
    ]); 
} 

回答

0

我已經找到了後置代號參數,在下面的鏈接

刪除路由
https://github.com/zircote/swagger-php/tree/master/Examples 
0

咆哮laravel路線招搖/放/刪除。

Route::post('/api/user', '[email protected]'); 
Route::put('/api/user/{user_id}', '[email protected]'); 
Route::delete('/api/user/{user_id}', '[email protected]'); 

對於郵政

/** 
    * @SWG\Post(
    *  path="/api/user", 
    *  tags={"User"}, 
    *  operationId="ApiV1saveUser", 
    *  summary="Add User", 
    *  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" 
    *  ), 
    */ 

認沽

/** 
    * @SWG\Put(
    *  path="/api/user/{user_id}", 
    *  tags={"User"}, 
    *  operationId="ApiV1UpdateUser", 
    *  summary="Update User", 
    *  consumes={"application/x-www-form-urlencoded"}, 
    *  produces={"application/json"}, 
    *  @SWG\Parameter(
    *   name="user_id", 
    *   in="path", 
    *   required=true, 
    *   type="string" 
    *  ), 
    *  @SWG\Parameter(
    *   name="name", 
    *   in="formData", 
    *   required=true, 
    *   type="string" 
    *  ), 
    *  @SWG\Response(
    *   response=200, 
    *   description="Success" 
    *  ), 
    */ 

對於刪除

/** 
    * @SWG\Delete(
    *  path="/api/user/{user_id}", 
    *  tags={"User"}, 
    *  operationId="ApiV1DeleteUser", 
    *  summary="Delete User", 
    *  @SWG\Parameter(
    *   name="user_id", 
    *   in="path", 
    *   required=true, 
    *   type="string" 
    *  ), 
    *  @SWG\Response(
    *   response=200, 
    *   description="Success" 
    *  ), 
    */ 
+0

謝謝,我會檢查這個 – Arvind

+0

好的,如果你有任何困惑,你可以告訴我。謝謝 –

+0

雅肯定,我會 – Arvind