phpswaggeropenapiswagger-php

Swagger for PHP array of arrays


I am trying to create a response example that should return an array like this:

[
  [
    "Shop Name",
    "53.7094190",
    "-1.9084720"
    ,1
  ]
]

For this I am using this code:

*   @OA\Response(
*     response= "default",
*     description="Success: Array of shops",
*     @OA\MediaType(
*       mediaType="text/plain",
*         @OA\Schema(
*           type = "array",
*           @OA\Items( type="array",
*              @OA\Items(type="string", default="'Bridge Balti','53.7094190','-1.9084720',1"),
*           ),
*         )
*     )
*   )

And I am getting this in swagger hub:

[
  [
    "string"
  ]
]

Solution

  • If you just want to display an example in swagger ui, then you need to use the "example" parameter.

    @OA\Items(type="string",example="'Bridge Balti','53.7094190','-1.9084720',1")