I am trying to send an array using swagger. But when I check the array in inspect mode, I notice that the array being send is just a string and is not an array
/**
* @OA\Post(
* path="/api/update-landing-page",
* summary="Update Landing Page",
* description="Update Landing Page",
* tags={"Landing Page Backend"},
* security={{"bearer": {} }},
* @OA\RequestBody(
* required=true,
* @OA\MediaType(
* mediaType="multipart/form-data",
* @OA\Schema(
* required={"businesses","image"},
* @OA\Property(
* property="businesses",
* description="Business ID",
* type="array",
* @OA\Items(type="string", format="id"),
* ),
* @OA\Property(property="image", type="string", format="binary")
* )
* )
* ),
* @OA\Response(
* response=200,
* description="",
* @OA\MediaType(
* mediaType="application/json",
* )
* )
* )
*/
I want to have an array of business IDs. Which look something like this businesses: [1,2,3].
But When I click in inspect mode, I notice it turns into a string
How do I make it turn into an array?
Thanks for taking you time and appreciate it.
I managed to solve this problem with:
@OA\Property(
property="businesses[]",
description="Business ID",
type="array",
collectionFormat="multi",
@OA\Items(type="string", format="id"),
),
Not sure whether this will help others, but this is what works for me.