api-platform / api-platform/core

Allow dot in IRI

Đang mở
#8,003 2 bình luận 14 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
PHP
Star
2.6k
Fork
980
Merge trung bình
2 ngày 4 giờ
Pull request đã merge (30 ngày)
49

Mô tả

**Description**
It is currently not possible to have a dot "**.**" in an IRI.
Effectively, posting a resource containg a dot in its `id` would lead to the following error : "Unable to generate an IRI for "MyClass", triggered into **api-platform/core/src/Bridge/Symfony/Routing/IriConverter.php** line 155".

Behind the scene it is an error from **symfony/routing/Generator/UrlGenerator.php line 193** : Parameter "id" for route "my_route_get_item" must match "[^/\.]++" ("iri.withdot" given) to generate a corresponding URL.

It seems to me that it should be allowed to have a dot in an IRI as it's not part of the reserved URI characters.

**How to reproduce**
Try to post a resource (Entity, DTO) with an id containing a dot.

**Possible Solution**
For POST operations : change in **api-platform/core/src/Bridge/Symfony/Routing/Router.php**, the `generate()` method for
```
public function generate($name, $parameters = [], $referenceType = self::ABS_PATH)
{
// Disable strict_requirements to allow dot in IRIs
$this->router->setOption('strict_requirements', false);
return $this->router->generate($name, $parameters, self::CONST_MAP[$referenceType]);
}
```
**Additional Context**
Allowing a dot in IRIs would lead to troubles with GET operations as an IRI like "a.b" would lead to the following error : **Format \"b\" is not supported**. Effectively, **b** would be considered to be the format. In this case, maybe it could be possible to specify the format
in a Accept header only.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.