Api: error with array in annotation for doc

Created on 21 May 2018  路  2Comments  路  Source: dingo/api

| Q | A
| ----------------- | ---
| Bug? | yes
| New Feature? | no
| Framework | Laravel
| Framework version | 5.6.22
| Package version | 2.0.0-alpha2
| PHP version | 7.2.4

Actual Behaviour

I want to add the response for the api doc

     * @Transaction({
     *      @Request("email=foo&password=bar", contentType="application/x-www-form-urlencoded"),
     *      @Response(200, body={"token": "JWT TOKEN","token_type" : "bearer","expires_in" : "xxxxx","status_code": 200,"message": "User Authenticated"}),
     *      @Response(401, body={"message": "401 Unauthorized","status_code": 401}),
     *      @Response(422, body={"message": "The given data was invalid.","errors": {"email": ["validation.required"],"password": ["validation.required"]},"status_code": 422})
     * })

i have got this error

In AnnotationException.php line 42:

  [Syntax Error] Expected PlainValue, got '[' at position 501 in method App\Http\Controllers\Api\Auth\AuthController:
  :login().

Expected Behaviour

I just want to the doc accept my array

Steps to Reproduce

put an array inside of annotation

Most helpful comment

Just use curly braces where you need to define array.
Documentation generator will detect where multiple objects are and display the array. So for your case:

 * @Transaction({
 *      @Request("email=foo&password=bar", contentType="application/x-www-form-urlencoded"),
 *      @Response(200, body={"token": "JWT TOKEN","token_type" : "bearer","expires_in", "xxxxx","status_code": 200,"message": "User Authenticated"}),
 *      @Response(401, body={"message": "401 Unauthorized","status_code": 401}),
 *      @Response(422, body={"message": "The given data was invalid.","errors": {
 *         {"email": "validation.required"},
 *         {"password": "validation.required"}
 *      }},"status_code": 422})
 * })

All 2 comments

Just use curly braces where you need to define array.
Documentation generator will detect where multiple objects are and display the array. So for your case:

 * @Transaction({
 *      @Request("email=foo&password=bar", contentType="application/x-www-form-urlencoded"),
 *      @Response(200, body={"token": "JWT TOKEN","token_type" : "bearer","expires_in", "xxxxx","status_code": 200,"message": "User Authenticated"}),
 *      @Response(401, body={"message": "401 Unauthorized","status_code": 401}),
 *      @Response(422, body={"message": "The given data was invalid.","errors": {
 *         {"email": "validation.required"},
 *         {"password": "validation.required"}
 *      }},"status_code": 422})
 * })

thanks :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Kirtsen picture Kirtsen  路  3Comments

pedrolari picture pedrolari  路  3Comments

HTMHell picture HTMHell  路  4Comments

lloricode picture lloricode  路  3Comments

jhayiwg picture jhayiwg  路  3Comments