Php 如何使用Laravel在Swagger中生成post请求中的对象集合数组?
我正在尝试使用Laravel模型中的body请求生成Laravel-5.5 Swagger中的对象数组 我应该如何实现期望的输出Php 如何使用Laravel在Swagger中生成post请求中的对象集合数组?,php,swagger,laravel-5.5,Php,Swagger,Laravel 5.5,我正在尝试使用Laravel模型中的body请求生成Laravel-5.5 Swagger中的对象数组 我应该如何实现期望的输出 [ { "user_name": "string", "education": [ { "degree": [ { "year": "string", "name": "string" }, {
[
{
"user_name": "string",
"education": [
{
"degree": [
{
"year": "string",
"name": "string"
},
{
"year": "string",
"name": "string"
}
],
"hobby": [
{
"type": "string",
"description": "string"
},
{
"type": "string",
"description": "string"
}
]
}
]
}
]
有人能帮我吗
谢谢。在“用户”模型中,您只需要在下面的代码中添加以下内容
/**
* @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
{
//
}
在上面的代码中,当您发送请求时,您只需要进行编辑。
复制后粘贴后将度对象与“,”进行immidate。那你可以
在数组中传递多个对象
谢谢
请检查我下面的答案并解决您的问题。好的,如果您遇到问题,请告诉我。因此,我可以帮助您了解更多关于swagger的信息。是的,您将从laravel中的这个swagger注释代码中获得json响应。