saloonphp / saloon

🤠 Build beautiful API integrations and SDKs with Saloon
https://docs.saloon.dev
MIT License
2.03k stars 105 forks source link

Some properties are removed from the response body #404

Closed dimifontaine closed 4 months ago

dimifontaine commented 4 months ago

Hello. When using Insomnia or the Laravel Http client, I get the following response from an api :

{
    "@context": "\/easygym\/contexts\/Contact",
    "@id": "\/easygym\/contacts\/2938026",
    "@type": "http:\/\/schema.org\/Person",
    "number": "C2938026",
    "address": {
        "@id": "\/easygym\/addresses\/14169774",
        "@type": "Address",
        "addressCountry": "France",
        "addressCountryIso": "FR",
        "addressLocality": "TOULOUSE",
        "postalCode": "31000",
        "streetAddress": "1 place dupuy"
    }
}

When using a saloon request, all the properties beginning with an "@" are removed from the response. It happens when the Response is built as those properties are already not there when dumping the psrResponse body from the response constructor.

EDIT: more specifically, the properties already not there when doing the following in a custom response


 public function __construct(ResponseInterface $psrResponse, PendingRequest $pendingRequest, RequestInterface $psrRequest, ?Throwable $senderException = null)
    {
        dump($psrResponse->getBody()->getContents());

        parent::__construct($psrResponse, $pendingRequest, $psrRequest, $senderException);
    }