mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-08 18:49:26 +03:00
Added support for host parameter
This commit is contained in:
parent
0b7e734594
commit
5cc7cf212d
@ -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;
|
||||
}
|
||||
|
@ -19,6 +19,10 @@
|
||||
{% endif %}
|
||||
|
||||
<span class="path">
|
||||
{% if data.host is defined -%}
|
||||
{{ data.https ? 'https://' : 'http://' -}}
|
||||
{{ data.host -}}
|
||||
{% endif -%}
|
||||
{{ data.uri }}
|
||||
</span>
|
||||
</h3>
|
||||
@ -29,7 +33,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="content" style="display: {% if displayContent is defined and displayContent == true %}display{% else %}none{% endif %};">
|
||||
<div class="content" style="display: {% if displayContent is defined and displayContent == true %}display{% else %}none{% endif %};">
|
||||
<ul class="tabs">
|
||||
<li class="selected" data-pane="content">Documentation</li>
|
||||
{% if enableSandbox %}
|
||||
|
@ -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
|
||||
|
@ -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 (
|
||||
|
Loading…
x
Reference in New Issue
Block a user