예제 #1
0
 /**
  * get all endpoints for an API
  *
  * @param boolean $withHost    attach host name to the url
  * @param bool    $forceReload Switch to force a new api definition object will be provided.
  *
  * @return array
  */
 public function getAllEndpoints($withHost = false, $forceReload = false)
 {
     $this->loadApiDefinition($forceReload);
     $host = empty($this->options['host']) ? '' : $this->options['host'];
     $prefix = self::PROXY_ROUTE;
     if (isset($this->options['prefix'])) {
         $prefix .= "/" . $this->options['prefix'];
     }
     $retVal = array();
     if (is_object($this->definition)) {
         $retVal = $this->definition->getEndpoints($withHost, $prefix, $host);
     }
     return $retVal;
 }
예제 #2
0
 /**
  * Sets the destination host for the api definition.
  *
  * @param ApiDefinition $apiDef Configuration for the swagger api to be recognized.
  *
  * @return void
  */
 private function registerHost(ApiDefinition $apiDef)
 {
     try {
         $host = $this->document->getHost();
     } catch (MissingDocumentPropertyException $e) {
         $host = $this->fallbackData['host'];
     }
     $apiDef->setHost($host);
 }
예제 #3
0
 /**
  * test schema
  *
  * @return void
  */
 public function testAddSchema()
 {
     $endpoint = "test/schema/endpoint";
     $testschema = new \stdClass();
     $testschema->name = "test123";
     $testschema->description = "This is a description";
     $sut = new ApiDefinition();
     $sut->addSchema($endpoint, $testschema);
     $schema = $sut->getSchema($endpoint);
     $this->assertInstanceOf("\\stdClass", $schema);
     $this->assertEquals($testschema->name, $schema->name);
     $this->assertEquals($testschema->description, $schema->description);
     $this->assertInstanceOf("\\stdClass", $sut->getSchema("blablabla/endpoint"));
 }