【问题标题】:How to fix ErrorException: @OA\Items() is required when @OA\Property() has type "array"?如何修复ErrorException:@OA\Property() 的类型为“array”时需要@OA\Items()?
【发布时间】:2019-05-25 14:27:04
【问题描述】:

我尝试添加任意类型的嵌套数组。 这些是我的注释:

* @OA\Property(
*      @OA\Schema(
*          type="array",
*          @OA\Items(
*              type="array",
*              @OA\Items(type={})
*          )
*      ),
*      description="bla bla bla"
* )

【问题讨论】:

  • 如果将@OA\Items(type={}) 替换为@OA\Items() 会怎样?
  • 我已经试过了,不行

标签: php openapi swagger-php


【解决方案1】:

我找到了解决办法:

 * @OA\Property(
 *      type="array",
 *      @OA\Items(
 *          type="array",
 *          @OA\Items()
 *      ),
 *      description="bla bla bla"
 * )

问题是@OA\Schema

【讨论】:

  • 谢谢,这真的很有帮助!
  • 如何设置字段的必填项?
  • * @OA\Parameter( * name="", * in="path", * @OA\Schema(type="string"), * required=true, * description="" * ),
猜你喜欢
  • 2018-03-10
  • 2014-05-19
  • 2022-11-22
  • 2022-07-05
  • 2022-01-05
  • 2022-08-15
  • 2023-01-27
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多