首页 > 解决方案 > 如何在 swagger-php 流明中添加多维数组?

问题描述

我学习了 swagger-php,我需要通过 swagger 在文档中添加多维数组。我的代码

    /**
 *Send Email method
 * @OA\Post (
 *     path="/v1/sendEmail",
 *     operationId="sendEmail",
 *     summary="Send email",
 *     description="",
 *     @OA\RequestBody(
 *         @OA\MediaType(
 *             mediaType="application/json",
 *             @OA\Schema(
 *                 type="array",
 *                 @OA\Items(
 *                     @OA\Property(
 *                         property="action",
 *                         type="string",
 *                     ),
 *                 ),
 *             ),
 *         ),
 *     ),
 *     @OA\Response(
 *         response=200,
 *         description="OK",
 *         @OA\MediaType(
 *             mediaType="application/json",
 *             @OA\Schema(
 *                 @OA\Property(
 *                     property="result",
 *                     type="string"
 *                 ),
 *                 @OA\Property(
 *                     property="message",
 *                     type="string"
 *                 ),
 *                 example={"result": "Ok", "message": "Success"}
 *             )
 *         )
 *     )
 * )
 *
 *
 *
 * @param Request $request
 * @return JsonResponse
 */
public function sendEmail(Request $request): JsonResponse
{
    return response()->json('ok');
}

但我需要在“操作”之后添加类型为数组的属性“字母”。但我不能使用这样的东西

     *                     @OA\Property(
 *                         property="letter",
 *                         type="array",
 *                     ),

因为我在属性中通过类型数组得到错误。

我怎样才能在里面添加数组?

谢谢

标签: lumenswagger-php

解决方案


推荐阅读