Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collection Name in response of POST_COLLECTION falls back to default value "items" #40

Open
ppaulis opened this issue Mar 21, 2023 · 0 comments
Labels
Bug Something isn't working

Comments

@ppaulis
Copy link
Contributor

ppaulis commented Mar 21, 2023

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

@ppaulis ppaulis added the Bug Something isn't working label Mar 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant