2017-05-30 47 views
0

我安裝了「darkaonline/l5-swagger」:「〜3.0」來獲取我的Laravel 5.3項目中的Swagger,並且我想爲用戶設置一個api_key值,通過swagger測試我的api get acces或者不會比較他輸入的api_key值與一個礦。swagger安全Laravel

我有這對我的security.php:

/** 
* @SWG\SecurityScheme(
* securityDefinition="api_key", 
* type="apiKey", 
* in="header", 
* name="api_key" 
*) 
*/ 

和我UserController的:

/** 
    * @SWG\Post(
    *  path="/add_user", 
    *  tags={"user"}, 
    *  operationId="adduser", 
    *  summary="Add a new user to the store", 
    *  description="", 
    *  produces={"application/xml", "application/json"}, 
    *  @SWG\Parameter(
    *   name="name", 
    *   in="formData", 
    *   type="string", 
    *   description="Name of the user", 
    *   required=true, 
    * ), 
    *  @SWG\Parameter(
    *   name="lastname", 
    *   in="formData", 
    *   type="string", 
    *   description="Lastname of the user", 
    *   required=true, 
    * ),  
    *  @SWG\Parameter(
    *   name="email", 
    *   in="formData", 
    *   type="string", 
    *   description="Email of the user", 
    *   required=true, 
    * ), 
    *  @SWG\Parameter(
    *   name="password", 
    *   in="formData", 
    *   type="string", 
    *   description="password of the user", 
    *   required=true, 
    * ), 
    *  @SWG\Parameter(
    *   name="website", 
    *   in="formData", 
    *   type="string", 
    *   description="website of the user", 
    *   required=true, 
    * ), 
    *  @SWG\Parameter(
    *   name="platform", 
    *   in="formData", 
    *   type="string", 
    *   description="website of the user", 
    *   required=true, 
    * ), 
    *  @SWG\Response(
    *   response=405, 
    *   description="Invalid input", 
    * ), 
    *  security={ 
    *   { 
    *    "api_key": {}, 
    *   } 
    *  }, 
    *) 
    */ 

,但我可以存儲一個新的用戶,即使我沒有一個API_KEY值增加我的網址或授權對話框。我錯過了什麼?

+0

@KhorneHoly謝謝我錯過了那部分 –

+0

嗨傑拉德,你可以在這個問題上建議我。 https://stackoverflow.com/questions/45839934/laravel-post-delete-put-routes-in-swagger – Arvind

回答

0

你仍然需要自己檢查apikey。 Swagger只是在那裏生成文檔,它不會影響您的實際代碼。