api-platform / api-platform/core
Unable to create an entity by passing a Uuid as a call from the client
- 主要語言
- PHP
- 星號
- 2.6k
- 分支
- 980
- 平均合併
- 2 天 5 小時
- 30 天內合併 PR
- 48
描述
**API Platform version(s) affected**: 3.4.0
**Symfony version(s) affected**: 6.4.10
**Description**
I am building a CQRS system based on symfony + apiplatform + ecotone.
My goal is to create a new entity with an ID passed by the client
When I try I get the error: "Update is not allowed for this operation."
If I enable "api_allow_update", I have to create a custom provider for GET, to retrieve Entity.
**How to reproduce**
Sample POST call
```
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"hostname": "string"
}
```
My Entity:
``` Tenant
{
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
#[Groups("registration")]
#[ApiProperty(writable: true, identifier: true, types: ['https://schema.org/identifier'])]
protected Uuid $id;
...
...
```
**Possible Solution**
**Additional Context**
POST(denormalizationContext: ['api_allow_update' => false, 'groups' => ['registration']],)

POST(denormalizationContext: ['api_allow_update' => true, 'groups' => ['registration']],)

GET(provider: TenantProvider::class,)
Here I have to find an entity, with the Id!
```
public function provide(Operation $operation, array $uriVariables = [], array $context = []): Tenant|null
{
print_r($uriVariables); die;
```

貢獻指南
評估
這個 Issue 還沒有評估資料。