0

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"
  ]
]

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

I'm trying this solution but somehow it ends as a single item for me: "test": [ "'Bridge Balti','53.7094190','-1.9084720',1" ] Any chance I might be doing it differently?
0

Accepted answer doen't work for me. Instead of array, it was showing as string. Following change works for me. ( Double quotes does the magic )

example="[""Bridge Balti"",""53.7094190"",""-1.9084720"",1]"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.