[英]Unable to generate an IRI when using mongoDb
I'm new to the API Platform framework, and for the project I'm working on we're required to use mongoDb. 我是API平台框架的新手,对于我正在从事的项目,我们需要使用mongoDb。
I followed the instructions on how to set it up with mongoDb ( see here ). 我遵循了有关如何使用mongoDb进行设置的说明( 请参阅此处 )。 But I installed
doctrine/mongodb-odm:2.0.x.-dev
instead of doctrine/mongodb-odm:^2.0.0@beta
so that the bin/console doctrine:mongodb:schema:create
command works... 但是我安装了
doctrine/mongodb-odm:2.0.x.-dev
而不是doctrine/mongodb-odm:^2.0.0@beta
因此bin/console doctrine:mongodb:schema:create
命令起作用了...
In any case, I created a very simple document based off the provided example: 无论如何,我根据提供的示例创建了一个非常简单的文档:
<?php
// api/src/Document/Test.php
namespace App\Document;
use ApiPlatform\Core\Annotation\ApiResource;
use Doctrine\ODM\MongoDB\Mapping\Annotations as ODM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ApiResource
*
* @ODM\Document
*/
class Test
{
/**
* @ODM\Id(strategy="INCREMENT", type="integer")
*/
private $id;
/**
* @ODM\Field(type="string")
* @Assert\NotBlank
*/
private $name;
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
}
However, the response I get is: "Unable to generate an IRI for the item of type \\"App\\\\Document\\\\Test\\""
. 但是,我得到的响应是:
"Unable to generate an IRI for the item of type \\"App\\\\Document\\\\Test\\""
。 But as you can see the ID-getter function is there, which seems the be the "usual" cause of the error. 但是正如您看到的那样,那里有ID-getter函数,这似乎是错误的“通常”原因。
The full Response Body can be found in this pastebin . 完整的响应正文可以在此pastebin中找到。
What am I missing? 我想念什么?
Thanks! 谢谢!
API平台2.4.0-beta的更新已解决了该问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.