mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Fix #1239: FosRestDescriber properly configures Parameter#pattern property.
Minor bugfix that configures `Parameter#pattern` property instead of `Parameter#format`. Tests provided that prove this implementation works as expected.
This commit is contained in:
parent
981a2b6293
commit
499886deab
@ -54,7 +54,7 @@ final class FosRestDescriber implements RouteDescriberInterface
|
||||
|
||||
$normalizedRequirements = $this->normalizeRequirements($annotation->requirements);
|
||||
if (null !== $normalizedRequirements) {
|
||||
$parameter->setFormat($normalizedRequirements);
|
||||
$parameter->setPattern($normalizedRequirements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class ApiController
|
||||
/**
|
||||
* @Route("/fosrest.{_format}", methods={"POST"})
|
||||
* @QueryParam(name="foo")
|
||||
* @RequestParam(name="bar")
|
||||
* @RequestParam(name="bar", requirements="\d+")
|
||||
*/
|
||||
public function fosrestAction()
|
||||
{
|
||||
|
@ -125,6 +125,10 @@ class FunctionalTest extends WebTestCase
|
||||
$this->assertTrue($parameters->has('foo', 'query'));
|
||||
$this->assertTrue($parameters->has('bar', 'formData'));
|
||||
|
||||
$barParameter = $parameters->get('bar', 'formData');
|
||||
$this->assertNotNull($barParameter->getPattern());
|
||||
$this->assertEquals('\d+', $barParameter->getPattern());
|
||||
|
||||
// The _format path attribute should be removed
|
||||
$this->assertFalse($parameters->has('_format', 'path'));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user