src/Model/Serializer.php
public function serialize(
        object $entity,
        string $modelName,
        array $context = []
    ): array {
        $out = $this->recursiveSerialize($entity, $modelName, 0, $context);

        if (is_string($out)) {
            throw new \RuntimeException(
                'recursiveSerialize should return an array for level 0 of serialization. This should not happen.'
            );
        }

        return $out;
    }
public function serialize(
        object $entity,
        string $modelName,
        array $context = []
    ): array {
        $out = $this->recursiveSerialize($entity, $modelName, 0, $context);

        if (is_string($out)) {
            throw new \RuntimeException(
                'recursiveSerialize should return an array for level 0 of serialization. This should not happen.'
            );
        }

        return $out;
    }
serialize entity for POST and PUT