当我们在使用API PLATFORM时,可能会遇到匿名ODM文档的弃用问题,这是由于更改了API注释格式所致。以下是解决此问题的步骤和示例代码:
步骤1:使用具名ODM文档替换匿名ODM文档。
//使用具名ODM文档 /**
collectionOperations={
"get"={
"method"="GET",
"path"="/resource"
},
"post"={
"method"="POST",
"path"="/resource",
"swagger_context"={
"summary"="Create a new resource"
}
}
},
itemOperations={
"put"={
"method"="PUT",
"path"="/resource/{id}",
"input"=ResourceType::class,
"normalization_context"={"groups"={"resource:read"}},
"swagger_context"={
"summary"="Modify resource"
}
},
"get"={
"method"="GET",
"path"="/resource/{id}",
"normalization_context"={"groups"={"resource:read"}},
"swagger_context"={
"summary"="Retrieve resource by ID"
}
}
},
shortName="Resource"
步骤2:更改ODM文档的名称。
/**
collectionOperations={
"get"={
"method"="GET",
"path"="/resource"
},
"post"={
"method"="POST",
"path"="/resource",
"swagger_context"={
"summary"="Create a new resource"
}
}
},
itemOperations={
"put"={
"method"="PUT",
"path"="/resource