我正在使用API平台框架进行搜索,正在获取空对象作为答复,但是对象数组的计数是正确的。
实体注释:-
@ApiResource(
attributes={
"order"={"Date": "DESC", "title": "ASC"},
"normalization_context"={"groups"={"student.read"},
"enable_max_depth"=true},
},
normalizationContext={
"groups"={"student.read"}
},
collectionOperations={
"get",
"post",
"get_list_students"={
"route_name"="api_student_list",
"normalization_context"={"groups"={"student.read"}}
},
},
denormalizationContext={
"groups"={"student.write"}
},
)
我有一个控制器,可以从数据库中获取学生,同时按如下方式指定注释:-
控制器注释:-
@Route(
path="/api/student/list",
name="api_student_list",
methods={"GET"},
defaults={
"_api_collection_operation_name"="get_list_students",
"_api_normalization_context"={"api_sub_level"=true},
"_api_swagger_context"={
"tags"={"student"},
"summary"="Retrieve a list of students",
"parameters" = {
{
"name" = "teacher_id",
"required" = false,
"type" = "string",
"in" = "query"
},
{
"name" = "school_id",
"required" = false,
"type" = "string",
"in" = "query"
},
{
"name" = "search_term",
"required" = false,
"type" = "string",
"in" = "query"
},
{
"name" = "order",
"required" = false,
"type" = "string",
"in" = "query",
"enum" = { "studentname" },
"description" = "studentname"
},
{
"name" = "direction",
"required" = false,
"type" = "string",
"in" = "query",
"enum" = { "ASC", "DESC" },
"description" = "ASC or DESC"
}
},
"responses"={
"200"={
"description"="Retrieve a list of students",
"schema"={
"type"="object",
"properties"={
}
}
}
}
}
}
)
/
我得到的结果是:-但计数正确是5个值
[
{},
{},
{},
{},
{}
]
答案 0 :(得分:0)
也许您是仅具有私有/受保护属性的json编码对象。 如果您var_dump其中一项是什么结果?