diff --git a/RouteDescriber/FosRestDescriber.php b/RouteDescriber/FosRestDescriber.php index 1a4615f..fef4b18 100644 --- a/RouteDescriber/FosRestDescriber.php +++ b/RouteDescriber/FosRestDescriber.php @@ -54,7 +54,7 @@ final class FosRestDescriber implements RouteDescriberInterface $normalizedRequirements = $this->normalizeRequirements($annotation->requirements); if (null !== $normalizedRequirements) { - $parameter->setFormat($normalizedRequirements); + $parameter->setPattern($normalizedRequirements); } } } diff --git a/Tests/Functional/Controller/ApiController.php b/Tests/Functional/Controller/ApiController.php index db401ee..8ec78ba 100644 --- a/Tests/Functional/Controller/ApiController.php +++ b/Tests/Functional/Controller/ApiController.php @@ -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() { diff --git a/Tests/Functional/FunctionalTest.php b/Tests/Functional/FunctionalTest.php index 38ff95e..2069ed3 100644 --- a/Tests/Functional/FunctionalTest.php +++ b/Tests/Functional/FunctionalTest.php @@ -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')); }