Ejemplo n.º 1
0
 /**
  * check if version is returned in header
  *
  * @return void
  */
 public function testVersionHeader()
 {
     $client = static::createRestClient();
     $client->request('GET', '/');
     $composer = new CoreUtils();
     $response = $client->getResponse();
     $this->assertEquals($composer->getVersion(), $response->headers->get('X-Version'));
 }
Ejemplo n.º 2
0
 /**
  * Returns all version numbers
  *
  * @return \Symfony\Component\HttpFoundation\Response $response Response with result or error
  */
 public function versionsAction()
 {
     $response = $this->getResponse()->setStatusCode(Response::HTTP_OK);
     $response->headers->set('Content-Type', 'application/json');
     $versions = array();
     $versions['versions'] = $this->coreUtils->getVersion();
     return $this->render('GravitonRestBundle:Main:index.json.twig', ['response' => json_encode($versions)], $response);
 }
Ejemplo n.º 3
0
 /**
  * check if version is returned in header
  *
  * @return void
  */
 public function testVersionHeader()
 {
     $client = static::createRestClient();
     $client->request('GET', '/');
     $composer = new CoreUtils($this->getContainer()->getParameter('graviton.core.version.data'));
     $response = $client->getResponse();
     $this->assertEquals($composer->getVersionInHeaderFormat(), $response->headers->get('X-Version'));
 }
 /**
  * Adds a X-Version header to the response.
  *
  * @param FilterResponseEvent $event Current emitted event.
  *
  * @return void
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         // don't do anything if it's not the master request
         return;
     }
     /** @var \Symfony\Component\HttpFoundation\Response $response */
     $response = $event->getResponse();
     $response->headers->set('X-Version', $this->coreUtils->getVersion());
 }
Ejemplo n.º 5
0
 /**
  * Basic structure of the spec
  *
  * @return array Basic structure
  */
 private function getBasicStructure()
 {
     $ret = array();
     $ret['swagger'] = '2.0';
     $ret['info'] = array('version' => $this->coreUtils->getWrapperVersion()['version'], 'title' => 'Graviton REST Services', 'description' => 'Testable API Documentation of this Graviton instance.');
     $ret['basePath'] = '/';
     $ret['schemes'] = array('http', 'https');
     return $ret;
 }