我试图在Laravel-5.5 Swagger中使用Laravel中的body request生成对象数组。
我应该如何实现期望的输出?
[
{
"user_name": "string",
"education": [
{
"degree": [
{
"year": "string",
"name": "string"
},
{
"year": "string",
"name": "string"
}
],
"hobby": [
{
"type": "string",
"description": "string"
},
{
"type": "string",
"description": "string"
}
]
}
]
}
]有人能帮帮我吗?
谢谢。
发布于 2018-03-01 06:20:16
在“用户”模型中,只需将其放在代码下面即可。
/**
* @SWG\Definition(
* definition="User",
* type="array",
* @SWG\Items(
* type="object",
* @SWG\Property(type="string", property="user_name", description="User name"),
* @SWG\Property(type="array", property="education", description="Education",
* @SWG\Items(
* @SWG\Property(property="degree", type="object",
* type="array",
* @SWG\Items(
* @SWG\Property(property="year", type="string"),
* @SWG\Property(property="name", type="string"),
* ),
* ),
* @SWG\Property(property="hobby", type="object",
* type="array",
* @SWG\Items(
* @SWG\Property(property="type", type="string"),
* @SWG\Property(property="description", type="string"),
* ),
* ),
* ),
* ),
* ),
* ),
*/
class User extends Model
{
//
}在上面的代码中,当你发送请求的时候,你只需要编辑。复制粘贴后用",“完成度对象的复制。然后可以在数组中传递多个对象。 谢谢,
https://stackoverflow.com/questions/49043544
复制相似问题