mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Avoid "array to string conversion" error
This commit is contained in:
parent
19d4e37365
commit
d3bc49c3d1
@ -478,8 +478,10 @@ class ApiDoc
|
||||
$this->host = $route->getHost() ? : null;
|
||||
|
||||
//replace route placeholders
|
||||
foreach ($route->getDefaults() as $key => $value) {
|
||||
$this->host = str_replace('{' . $key . '}', $value, $this->host);
|
||||
foreach ($route->getDefaults() as $key => $value) {
|
||||
if (is_string($value)) {
|
||||
$this->host = str_replace('{' . $key . '}', $value, $this->host);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->host = null;
|
||||
|
@ -13,6 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\Annotation;
|
||||
|
||||
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||
use Nelmio\ApiDocBundle\Tests\TestCase;
|
||||
use Symfony\Component\Routing\Route;
|
||||
|
||||
class ApiDocTest extends TestCase
|
||||
{
|
||||
@ -373,4 +374,28 @@ class ApiDocTest extends TestCase
|
||||
$this->assertArrayHasKey(400, $map);
|
||||
$this->assertEquals($apiDoc->getOutput(), $map[200]);
|
||||
}
|
||||
|
||||
public function testSetRoute()
|
||||
{
|
||||
$route = new Route(
|
||||
'/path/{foo}',
|
||||
[
|
||||
'foo' => 'bar',
|
||||
'nested' => [
|
||||
'key1' => 'value1',
|
||||
'key2' => 'value2',
|
||||
]
|
||||
],
|
||||
[],
|
||||
[],
|
||||
'{foo}.awesome_host.com'
|
||||
);
|
||||
|
||||
$apiDoc = new ApiDoc([]);
|
||||
$apiDoc->setRoute($route);
|
||||
|
||||
$this->assertSame($route, $apiDoc->getRoute());
|
||||
$this->assertEquals('bar.awesome_host.com', $apiDoc->getHost());
|
||||
$this->assertEquals('ANY', $apiDoc->getMethod());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user