2014-12-27 36 views
5

我想在swagger文檔中爲POST指定默認的json值。我正在收到T_CLOSE_PARENTHESIS錯誤。我也試圖逃避」。如何在swigger php文檔中指定默認的json值?

/** 
    * @SWG\Api(path="/api/users", 
    * @SWG\Operation(
    *  method="POST", 
    *  summary="Register a user", 
    *  notes="Send a POST request along with required form parameters to add a new user", 
    *  type="string", 
    *  nickname="post-users", 
    *  authorizations={}, 
    *  @SWG\Parameter(
    *  name="email", 
    *  description="The email", 
    *  required=true, 
    *  type="json", 
    *  paramType="body", 
    *  allowMultiple=false, 
    *  defaultValue = "{ 
    "email":"pradeep****@gmail.com", 
    "first_name":"Pradeep", 
    "last_name":"Kumar", 
    "group":"subscriber", 
    "password":"password" 
}", 
    * ), 
    *  
    *  @SWG\ResponseMessage(code=200,message="Success"), 
    *  @SWG\ResponseMessage(code=400,message="Bad Request") 
    * ) 
    *) 
    */ 
+4

神 – Jimbo

回答

10

要在學說逃避" /註釋使用""

defaultValue="{""email"":""p****@gmail.com"",""first_name"":""Pradeep""}" 
+0

完美,只是我正在尋找的答案,這應該是公認的答案! – Matthijs

1

我猜你應該defaultValue轉換成單行線,而逃避報價以正斜槓。

+0

Fehguy的親愛的母親,我已經嘗試過了,也是我的問題提到 – prady00

+0

我已經這樣做了 - 。 defaultValue =「{\」email \「:\」pradeep **** @ gmail.com \「,\」first_name \「:\」Pradeep \「,\」last_name \「:\」Kumar \ 「group \」:\「subscriber \」,\「password \」:\「password \」}「 – prady00

+0

嗨,我想你需要在swagger-php存儲庫中打開一個問題:https:// github。 com/zircote/swagger -php – fehguy