Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify default json value in swagger php documentation?

I want to specify a default json value in swagger docs for POST. I am getting T_CLOSE_PARENTHESIS error. I have also tried escaping the ".

/**
     * @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")
     *   )
     * )
     */
like image 515
prady00 Avatar asked Dec 27 '14 08:12

prady00


2 Answers

To escape a " in a doctrine/annotation use ""

defaultValue="{""email"":""p****@gmail.com"",""first_name"":""Pradeep""}" 
like image 97
Bob Fanger Avatar answered Sep 24 '22 21:09

Bob Fanger


I'm guessing you should convert the defaultValue into a single line, and escape the quotes with a forward slash.

like image 34
fehguy Avatar answered Sep 23 '22 21:09

fehguy