Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

mozziehin's avatar

DarkaOnLine/l5-swagger Laravel Array Input Incorrect

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 businesses: 1,2,3

How do I make it turn into an array?

Thanks for taking your time and appreciate it.

0 likes
1 reply
mozziehin's avatar

I manage to solve this problem by

                   @OA\Property(
                       property="businesses[]",
                       description="Business ID",
                       type="array",
                       collectionFormat="multi",
                      @OA\Items(type="string", format="id"),
                  ),

Not sure whether this will help you, but this is what works for me.

Please or to participate in this conversation.