Remove '_links' property from _embedded resources on Laminas\HAL module

Hello everyone!

I am using "laminas-api-tools/api-tools": "^1.4.0". I am deploying a REST service (with HAL response format) on an endpoint named /countries. I currently receive the response below:

(see image 1)

However I would like to get rid of the _links property under each CountriesEntity resources, as the fetchOne method is not enabled here.

I tried using the 'force_self_link' => false in 'api-tools-hal' => [] of the module configuration, and the result look like this:

(see image 2)

But what I would like to achieve looks like this :

(see image 3)

Please mind that I would like to keep the pagination and the links to CountriesCollection.

How could I do this without removing the hydrator of my class CountriesEntity?

Here are the images:

Thank you in advance for your help!

To modify your hal output you need to setup a listener. Here’s a snapshot of some Apigility code which adds data to the hal payload. I expect you can delete data just as easily.

Thank you for your advice! It led me to the Laminas API Tools documentation where I found more information about the event. I tried implementing this function (see image 1-2) in my code and the outcome (see image 3) was exactly what I wanted.

However, I noticed afterward that it causes the Laminas API Tools Admin to fail loading existing APIs. Thus, I modified my code accordingly to the solution given in one of the Laminas API Tools’ Github Issues that corresponds to our problem.

Ultimately, here is the solution I have found: (see image 4).