- 深色/l5-摆动:8.0.2
- PHP版本:7.3.13
- 氧化锆/摇摆-PHP:3.1.0
- 操作系统:Windows
我创建了一个Contract ref
对象。现在我想在我的ContractController
中列出一个契约数组。我该怎么做呢?我在尝试将type=array
添加到OA\Items
中时收到了Couldn't find constant array
错误
/**
* @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);
}
}
/**
* @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;
}
2条答案
按热度按时间4xrmg8kj1#
使用
type="array",
(带有"
s)代替type=array,
wfveoks02#
我知道现在很晚了但是试着用
@OA\JsonContent
学院