I am currently adding example responses to my annotations and I came across a small problem:
Whenever my response includes an array of certain objects the swagger file doesn't get generated anymore.
My examples line looks like this:
examples={"application/json": {"message":"foobar","data":[{"id":1,"name":"Item 1"},{"id":2,"name":"Item 2"}]}},
The error I get:
"[Syntax Error] Expected PlainValue, got '[' in ....
Is it not possible to include arrays of objects in my example responses?
No luck with this? Seems like a major to not be able to use arrays in examples!
Use the doctrine array notation with { instead of [
Thanks @bfanger - did I miss this in the docs?
For anyone else that might need an example:
* @SWG\Response(
* response=200,
* description="An array of people",
* examples={"application/json":
* {"models": { { "id": 1, "name": "Tim" },{ "id": 2, "name": "Sean" } },
* "current_page": 2,
* "last_page": 3,
* "next_page_url": "/bookings?page=3&limit=50",
* "prev_page_url": "/bookings?page=1&limit=50"
* }
* },
You didn't miss it, it's not in our docs or the doctrine-project docs.
if you encounter better documentation about doctrine annotations let me know, i'll gladly link it in the Readme.
Most helpful comment
Use the doctrine array notation with
{instead of[