【问题标题】:DarkaOnLine/l5-swagger Laravel Array Input IncorrectDarkaOnLine/l5-swagger Laravel 数组输入不正确
【发布时间】:2021-09-22 11:16:55
【问题描述】:

我正在尝试使用 swagger 发送一个数组。但是当我在检查模式下检查数组时,我注意到正在发送的数组只是一个字符串而不是数组

/**
     * @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",
     *          )
     *     )
     * )
     */

我想要一组企业 ID。看起来像这样 企业:[1,2,3]。

但是当我在检查模式下单击时,我注意到它变成了一个字符串

如何让它变成一个数组?

感谢您抽出宝贵时间并感谢您。

【问题讨论】:

    标签: swagger swagger-php


    【解决方案1】:

    我设法解决了这个问题:

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

    不确定这是否对其他人有帮助,但这对我有用。

    【讨论】:

      猜你喜欢
      • 2022-06-17
      • 2022-07-19
      • 1970-01-01
      • 2018-07-03
      • 2019-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多