prady00
prady00

Reputation: 741

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")
     *   )
     * )
     */

Upvotes: 5

Views: 5794

Answers (2)

Bob Fanger
Bob Fanger

Reputation: 29897

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

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

Upvotes: 12

fehguy
fehguy

Reputation: 6824

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

Upvotes: 1

Related Questions