public function generateResponse()
    {
        $data = $this->getData();

        if ($data instanceof \Closure) {
            $data = $data();
        }

        $encoders = [new XmlEncoder(), new JsonEncoder()];
        $normalizers = [new GetSetMethodNormalizer()];
        $serializer = new Serializer($normalizers, $encoders);

        $response = new Response();
        $response->headers->set('Content-Type', 'application/'.$this->getFormat());
        $response->setContent($serializer->serialize($data, $this->getFormat()));

        return $response;
    }