我在PHP中生成了下面的数组,现在不知道如何使用锆石/swagger-php来定义它,如果您能帮助我,我将非常感激。
PHP数组
$arr = [
['name' => 'foo', 'age' => 1],
['name' => 'bar', 'age' => 2],
];
echo json_encode(['data' => $arr]);傲慢的文件。
* @OA\Response(response=200, description="successful operation",
* @OA\JsonContent(
* @OA\Property(property="data", type="array", @OA\Items(
* @OA\Property(type="array", @OA\Items(
* @OA\Property(property="name", type="string", example="foo"),
* @OA\Property(property="age", type="integer", example="12"),
* ))
* ))
* )
* ),结果是傲慢的ui。
{
"data": [
{
"": [
{
"name": "string",
"age": "integer"
}
]
}
]
}非常感谢。
发布于 2022-12-01 21:09:27
一个太多的Items
试一试
/**
* @OA\Response(
* response=200,
* @OA\JsonContent(
* type="array",
* @OA\Items(
* type="object",
* @OA\Property(type="string", property="name", example="Fred"),
* @OA\Property(type="int", property="age", example="52")
* )
* )
* )https://stackoverflow.com/questions/74639423
复制相似问题