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

Spiral's avatar

How can make this type of array in swagger php

I want to make this type of array in swagger php version 3 can you help about this i have 5 parameters in whcih one is base64 parameter in json body

{
  "products": [
    {
      "first_name": "string",
      "last_name": "string",
      "email": "string",
      "phone": "string",
      "resume": "string" ==> here i will send base64 format of resume file
    }
  ]
}

This code using but giving error products must be an array where as resume passing in base64 format

/**
* @OA\Schema(
*   schema="ProductRequest",
*   required={"products"},
*   @OA\Property(
*       property="products",
*       type="array",
*       @OA\Items(
*           @OA\Property(property="first_name", type="string"),
*           @OA\Property(property="last_name", type="string"),
*           @OA\Property(property="email", type="string"),
*           @OA\Property(property="phone", type="string"),
*           @OA\Property(property="resume", type="string", format="byte"),
*       ),
*    )
* )
*/

/**
* @OA\RequestBody(
*   request="Product",
*   required=true,
*   description="Bulk products Body",
*   @OA\MediaType(
*     mediaType="multipart/form-data",
*     @OA\Schema(ref="#/components/schemas/ProductRequest")
*   )
* )
*/

/**
* @OA\Post(
*   path="/prodcuts/save",
*   tags={"Prodcuts"},
*   summary="Post bulk products",
*   description="Return bulk products",
*      @OA\Parameter(
*          name="id",
*          required=true,
*          in="query",
*          @OA\Schema(
*              type="string",
*          )
*     ),
*   @OA\RequestBody(ref="#/components/requestBodies/Product"),
*   @OA\Response(
*       response=200,
*       description="Successful operation",
*   ),
* )
*/
0 likes
2 replies
Spiral's avatar

Yes, I found the solution, but I will need to find out that solution in the project that I was working on

Please or to participate in this conversation.