How can send multipart/form-data file in application/json in swagger php

2k Views Asked by At

I want to uplaod a file in swagger-php in the json requestBody How can upload with the help of swagger anonations

Trying from lot of hours but not luck how can send and file in application/json array Can you help if any information about this so then i will solve my problem i have not concept about this

when this code generate in the terminal also not have any error and not shown in the request body in the swagger ui

/**
* @OA\Post(
*      path="/products/save",
*      tags={"Product"},
*      summary="Post bulk products",
*      description="Return bulk products",
*      @OA\RequestBody(
*       required=true,
*       description="Bulk products Body",
*       @OA\JsonContent(
*           @OA\Property(
*               property="products",
*               @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\MediaType(
*                       mediaType="multipart/form-data",
*                       @OA\Schema(
*                           @OA\Property(
*                               property="resume",
*                               type="file",
*                               format="file"
*                           ),
*                       )
*                  )
*               ),
*           )
*       )
*     ),
* )
*/
1

There are 1 best solutions below

0
On
@OA\RequestBody(
    @OA\MediaType(
        mediaType="multipart/form-data",
        @OA\Schema(
            allOf={
                @OA\Schema(ref="#components/schemas/item"),
                @OA\Schema(
                    @OA\Property(
                        description="Item image",
                        property="item_image",
                        type="string", format="binary"
                    )
                )
            }
        )
    )
),