diff --git a/src/Client.php b/src/Client.php index 9a1e84f..df2e436 100644 --- a/src/Client.php +++ b/src/Client.php @@ -41,9 +41,9 @@ use Psr\Http\Message\UriInterface; use Psr\Log\LoggerInterface; use Psr\Log\NullLogger; -use Symfony\Component\Serializer\Context\Normalizer\ObjectNormalizerContextBuilder; use Symfony\Component\Serializer\Encoder\JsonEncoder; use Symfony\Component\Serializer\NameConverter\CamelCaseToSnakeCaseNameConverter; +use Symfony\Component\Serializer\Normalizer\AbstractObjectNormalizer; use Symfony\Component\Serializer\Normalizer\BackedEnumNormalizer; use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; @@ -178,16 +178,18 @@ private function requestRaw(string $method, string|UriInterface $uri, array|\Jso new JsonSerializableNormalizer(), new ObjectNormalizer( nameConverter: new CamelCaseToSnakeCaseNameConverter(), - defaultContext: (new ObjectNormalizerContextBuilder()) - ->withPreserveEmptyObjects(true) - ->toArray(), + defaultContext: [ + AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS => true, + ], ), ], [new JsonEncoder()], ); if ($payload !== null) { - $body = $serializer->serialize($payload, 'json'); + $body = $serializer->serialize($payload, 'json', [ + AbstractObjectNormalizer::PRESERVE_EMPTY_OBJECTS => true, + ]); $request = $request->withBody( // Satisfies empty body requests.