mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Use FOSRest *Param::$key when defined
This commit is contained in:
parent
ebf7fa589b
commit
b88793267e
@ -39,8 +39,10 @@ final class FosRestDescriber implements RouteDescriberInterface
|
||||
|
||||
foreach ($this->getOperations($api, $route) as $operation) {
|
||||
foreach ($annotations as $annotation) {
|
||||
$parameterName = $annotation->key ?? $annotation->getName(); // the key used by fosrest
|
||||
|
||||
if ($annotation instanceof QueryParam) {
|
||||
$name = $annotation->getName().($annotation->map ? '[]' : '');
|
||||
$name = $parameterName.($annotation->map ? '[]' : '');
|
||||
$parameter = $operation->getParameters()->get($name, 'query');
|
||||
$parameter->setAllowEmptyValue($annotation->nullable && $annotation->allowBlank);
|
||||
|
||||
@ -48,11 +50,11 @@ final class FosRestDescriber implements RouteDescriberInterface
|
||||
} else {
|
||||
$body = $operation->getParameters()->get('body', 'body')->getSchema();
|
||||
$body->setType('object');
|
||||
$parameter = $body->getProperties()->get($annotation->getName());
|
||||
$parameter = $body->getProperties()->get($parameterName);
|
||||
|
||||
if (!$annotation->nullable && $annotation->strict) {
|
||||
$requiredParameters = $body->getRequired();
|
||||
$requiredParameters[] = $annotation->getName();
|
||||
$requiredParameters[] = $parameterName;
|
||||
|
||||
$body->setRequired(array_values(array_unique($requiredParameters)));
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ class FOSRestController
|
||||
/**
|
||||
* @Route("/fosrest.{_format}", methods={"POST"})
|
||||
* @QueryParam(name="foo", requirements=@Regex("/^\d+$/"))
|
||||
* @RequestParam(name="bar", requirements="\d+")
|
||||
* @RequestParam(name="Barraa", key="bar", requirements="\d+")
|
||||
* @RequestParam(name="baz", requirements=@IsTrue)
|
||||
*/
|
||||
public function fosrestAction()
|
||||
|
Loading…
x
Reference in New Issue
Block a user