对于我的项目,我创建了一个实体类别。它的存储库类从resp扩展了NestedTreeRepository。 STOF扩展名。我实现了一个自定义端点,以在树中移动类别。该功能运行良好,但是我正在使用庞大的文档。
我遵循api平台文档中的说明,但没有成功。
App \ Entity \ Cagegory:
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\ORM\PersistentCollection;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use ApiPlatform\Core\Annotation\ApiResource;
use \DateTime;
use \DateTimeInterface;
/**
* @ApiResource(attributes={
* "denormalization_context"={"groups"={"tree"}},
* "item_operations"={
* "get"={"method"="GET"},
* "put"={"method"="PUT"},
* "delete"={"method"="DELETE"},
* "moveCategory"={
* "method"="GET",
* "route_name"="category_move",
* "swagger_context" = {
* "parameters" = {
* {
* "name" = "id",
* "in" = "path",
* "required" = "true",
* "type" = "integer"
* },
* {
* "name" = "amount",
* "in" = "path",
* "required" = "true",
* "type" = "integer"
* }
* },
* "responses" = {
* "200" = {
* "description" = "The category has been moved"
* }
* }
* }
* }
* }
* })
*
* @Gedmo\Tree(type="nested")
* @ORM\Table(name="categories")
* use repository for handy tree functions
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\NestedTreeRepository")
*/
class Category
...
config / routes.yaml:
category_move:
path: /api/categories/{id}/move/{amount}
methods: [GET]
defaults:
_controller: App\Controller\CategoryController::move
_api_resource_class: App\Entity\Category
_api_item_operation_name: moveCategory
当我重新加载swagger页面时,它仍显示标准操作,但不显示我的自定义端点。
有什么想法吗?