mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Merge pull request #780 from damienalexandre/fixArrayToString
Fix Array to string conversion error on array requirements
This commit is contained in:
commit
5d9c47bbad
@ -83,6 +83,10 @@ class FosRestHandler implements HandlerInterface
|
||||
return substr($class, strrpos($class, '\\')+1);
|
||||
}
|
||||
|
||||
if (is_array($requirements) && isset($requirements['rule'])) {
|
||||
return (string) $requirements['rule'];
|
||||
}
|
||||
|
||||
return (string) $requirements;
|
||||
}
|
||||
|
||||
|
@ -175,4 +175,18 @@ class FosRestHandlerTest extends WebTestCase
|
||||
$this->assertArrayHasKey('dataType', $parameter);
|
||||
$this->assertEquals('string[]', $parameter['dataType']);
|
||||
}
|
||||
|
||||
public function testWithRequestParamArrayRequirements()
|
||||
{
|
||||
$container = $this->getContainer();
|
||||
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
||||
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::routeWithQueryParamArrayRequirementsAction', 'test_route_29');
|
||||
|
||||
$this->assertNotNull($annotation);
|
||||
$filters = $annotation->getFilters();
|
||||
|
||||
$this->assertArrayHasKey('param1', $filters);
|
||||
$this->assertArrayHasKey('requirement', $filters['param1']);
|
||||
$this->assertEquals('regexp', $filters['param1']['requirement']);
|
||||
}
|
||||
}
|
||||
|
@ -398,4 +398,12 @@ class TestController
|
||||
public function routeWithHostAction()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @ApiDoc()
|
||||
* @QueryParam(name="param1", requirements={"rule": "regexp", "error_message": "warning"}, description="Param1 description.")
|
||||
*/
|
||||
public function routeWithQueryParamArrayRequirementsAction()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -238,3 +238,8 @@ test_route_28:
|
||||
requirements:
|
||||
domain: "%domain_dev%|%domain_prod%"
|
||||
defaults: { _controller: NelmioApiDocTestBundle:Test:routeWithHost, domain: "%domain_dev%", _format: json }
|
||||
|
||||
test_route_29:
|
||||
path: /z-query-param-array-requirements
|
||||
methods: [GET]
|
||||
defaults: { _controller: NelmioApiDocTestBundle:Test:routeWithQueryParamArrayRequirementsAction }
|
||||
|
Loading…
x
Reference in New Issue
Block a user