-
-
Notifications
You must be signed in to change notification settings - Fork 20
Description
Bug Report
| Q | A |
|---|---|
| Version(s) | 1.9.0 |
Summary
When creating multiple entities in a POST_COLLECTION request, the name of the collection in the HAL response is the default name items instead of the Collection Name defined in the Interface.
Current behavior
Example:
{
"_links": {
"self": {
"href": "..."
},
"first": {
"href": "..."
},
"last": {
"href": "..."
}
},
"_embedded": {
"items": [ <========================= Uses default value "items" instead of Collection Name
{
"id": "..."
}
]
},
"page_count": 1,
"page_size": 30,
"total_items": 3,
"page": 1
}
Looking at the module.config.php file, the collection_name is present in the api-tools-rest section and it's used for GET collection calls :
'api-tools-rest' => array(
'tms\\V1\\Rest\\MyController\\Controller' => array(
'listener' => '...',
'route_name' => '...',
'route_identifier_name' => '...',
'collection_name' => 'myCollection',
However the POST collection call doesn't use this key/value pair.
If, on the other hand, I manually add the collection_name to the Metadata Map, then the collection name is set correctly:
'api-tools-hal' => array(
'metadata_map' => array(
'tms\\V1\\Rest\\MyResource\\MyResourceCollection' => array(
'entity_identifier_name' => 'id',
'route_name' => '...',
'route_identifier_name' => '...',
'is_collection' => true,
'collection_name' => 'myCollection'
),
How to reproduce
Create multiple entities in a single POST call.
Expected behavior
I would expect the collection name of the POST_COLLECTION response to match the collection_name from the api-tools-rest section of the module.config.php file.
Thanks and best regards,
Pascal