diff --git a/Annotation/ApiDoc.php b/Annotation/ApiDoc.php
index e678411..ff9e480 100644
--- a/Annotation/ApiDoc.php
+++ b/Annotation/ApiDoc.php
@@ -80,6 +80,11 @@ class ApiDoc
*/
private $method;
+ /**
+ * @var string
+ */
+ private $host;
+
/**
* @var string
*/
@@ -302,6 +307,7 @@ class ApiDoc
public function setRoute(Route $route)
{
$this->route = $route;
+ $this->host = $route->getHost() ?: null;
$this->uri = $route->getPattern();
$this->method = $route->getRequirement('_method') ?: 'ANY';
}
@@ -314,6 +320,22 @@ class ApiDoc
return $this->route;
}
+ /**
+ * @return string
+ */
+ public function getHost()
+ {
+ return $this->host;
+ }
+
+ /**
+ * @param string $host
+ */
+ public function setHost($host)
+ {
+ $this->host = $host;
+ }
+
/**
* @return boolean
*/
@@ -389,6 +411,10 @@ class ApiDoc
'uri' => $this->uri,
);
+ if ($host = $this->host) {
+ $data['host'] = $host;
+ }
+
if ($description = $this->description) {
$data['description'] = $description;
}
diff --git a/Resources/views/method.html.twig b/Resources/views/method.html.twig
index 99e1369..6744316 100644
--- a/Resources/views/method.html.twig
+++ b/Resources/views/method.html.twig
@@ -19,6 +19,10 @@
{% endif %}
+ {% if data.host is defined -%}
+ {{ data.https ? 'https://' : 'http://' -}}
+ {{ data.host -}}
+ {% endif -%}
{{ data.uri }}
@@ -29,7 +33,7 @@
-
+
- Documentation
{% if enableSandbox %}
diff --git a/Tests/Fixtures/app/config/routing.yml b/Tests/Fixtures/app/config/routing.yml
index 43c6dd2..4dd5ea9 100644
--- a/Tests/Fixtures/app/config/routing.yml
+++ b/Tests/Fixtures/app/config/routing.yml
@@ -6,6 +6,7 @@ test_route_1:
test_route_2:
pattern: /tests.{_format}
+ host: api.test.dev
defaults: { _controller: NelmioApiDocTestBundle:Test:postTest, _format: json }
requirements:
_method: POST
@@ -76,6 +77,7 @@ test_service_route_1:
test_service_route_2:
pattern: /tests.{_format}
+ host: api.test.dev
defaults: { _controller: nemlio.test.controller:postTestAction, _format: json }
requirements:
_method: POST
diff --git a/Tests/Formatter/SimpleFormatterTest.php b/Tests/Formatter/SimpleFormatterTest.php
index 5c93291..332117f 100644
--- a/Tests/Formatter/SimpleFormatterTest.php
+++ b/Tests/Formatter/SimpleFormatterTest.php
@@ -100,6 +100,7 @@ class SimpleFormatterTest extends WebTestCase
array (
'method' => 'POST',
'uri' => '/tests.{_format}',
+ 'host' => 'api.test.dev',
'description' => 'create test',
'parameters' =>
array (
@@ -142,6 +143,7 @@ class SimpleFormatterTest extends WebTestCase
array (
'method' => 'POST',
'uri' => '/tests.{_format}',
+ 'host' => 'api.test.dev',
'description' => 'create test',
'parameters' =>
array (