首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >找不到常数数组

找不到常数数组
EN

Stack Overflow用户
提问于 2020-10-02 04:13:01
回答 1查看 1.2K关注 0票数 1
  • darkaonline/l5-swagger: 8.0.2
  • PHP版本: 7.3.13
  • zircote/swagger-php: 3.1.0
  • OS: Windows

我创建了一个Contract ref对象。现在,在我的ContractController中,我想列出一系列合同。我该怎么做呢?当我试图在Couldn't find constant array中添加type=array时,我得到了这个错误OA\Items

代码语言:javascript
复制
/**
 * @OA\Info(title="Contract API", version="1")
 */

class ContractController extends Controller
{
    /**
     * @OA\Post(
     *     path="/api/v1/contract/list",
     *     tags={"contact"},
     *     summary="List Contract",
     *     operationId="list",
     *     @OA\Parameter(
     *         name="keyword",
     *         in="path",
     *         description="keyword to search contracts",
     *         required=false,
     *         @OA\Schema(
     *             type="string"
     *         )
     *     ),
     *     @OA\Parameter(
     *         name="lang_code",
     *         in="path",
     *         description="lang_code define language client used",
     *         required=false,
     *         @OA\Schema(
     *             type="string",
     *         )
     *     ),
     *     @OA\Response(
     *         response=200,
     *         description="successful",
     *         @OA\JsonContent(
     *              @OA\Items(
     *                  type=array, #This is where I got the error
     *                  ref="#/components/schemas/Contract"
     *              )
     *         )
     *     ),
     *     @OA\Response(
     *         response=400,
     *         description="Wrong"
     *     )
     * )
     */
    public function list(Request $request)
    {
        $contracts = Contract::factory()->count(10)->make();
        return response()->json([
            'message' => 'good',
            'contracts' => $contracts
        ], 200);
    }
}
代码语言:javascript
复制
/**
 * @OA\Schema(
 *     description="Contract model",
 *     type="object",
 *     title="Contract model"
 * )
 */
class Contract extends Model
{
    use HasFactory;

    /**
     * The unique identifier of a product in our catalog.
     *
     * @var integer
     * @OA\Property(format="int64", example=1)
     */
    public $id;

    /**
     * @var string
     * @OA\Property(format="string", example="contract 001")
     */
    public $contract_title;
}
EN

回答 1

Stack Overflow用户

发布于 2020-10-02 14:17:12

使用type="array", (与"一起使用)而不是type=array,

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64166065

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档