-
-
Notifications
You must be signed in to change notification settings - Fork 923
Closed
Labels
Description
Upper Case attribute name example, that doesn't work:
Btw, there is no mention about @ApiProperty(identifier=true)
in docs :/ !
/**
* @ApiProperty(identifier=true)
*/
protected $Id;
Resource:
AppBundle\Entity\Project:
itemOperations:
get:
method: 'GET'
path: '/project/{id}'
Request
curl -X GET --header 'Accept: application/ld+json' 'http://127.0.0.1:81/project/48'
Response:
{
"@context": "/contexts/Error",
"@type": "hydra:Error",
"hydra:title": "An error occurred",
"hydra:description": "Parameter \"id\" for route \"api_projects_get_item\" must match \"[^/]++\" (\"\" given) to generate a corresponding URL.",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "/srv/api-platform/vendor/symfony/symfony/src/Symfony/Component/Routing/Generator/UrlGenerator.php",
"line": 163,
temporary solution is to define lower case attribute :
/**
* @var int
*/
protected $Id = null;
/**
* @ApiProperty(identifier=true)
* @var int
*/
protected $id = null;
Why I had to use upper case name? Because of bad SOAP service naming convention from vendor
What about to define identifier in resource.yml?
AppBundle\Entity\Project:
identifier: id
itemOperations:
get:
method: 'GET'
path: '/project/{id}'