Why Swagger UI array type field generates a string

16 views Asked by At

In symfony54, API controller, i have


     * @OA\RequestBody(
     *       @OA\MediaType(
     *           mediaType="multipart/form-data",
     *           @OA\Schema(
     *               @OA\Property(
     *                  property="email",
     *                  type="array",
     *                  @OA\Items(
     *                       type="string"
     *                  ),
     *               )
     *           )
     *       )
     *   )

I would like to ask , why Swagger UI result is "email=test1,test2" instead of "email[]=test1&email[]=test2" or email[0]=test&email[1]= test2.

When I get the email in php it is a string, not an array.

I have made many attempts , it seems that collectionFormat=multi can solve this problem , but it is valid only for parameters of type query or formData.

email=test1,test2 seems to be the default csv format.

How should I configure the API annotations to get arrays instead of strings?

0

There are 0 answers