mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Respect the spec in the FosRestDescriber (#1390)
This commit is contained in:
parent
fcb36d8e8d
commit
0e72b64e3c
@ -42,13 +42,21 @@ final class FosRestDescriber implements RouteDescriberInterface
|
||||
if ($annotation instanceof QueryParam) {
|
||||
$parameter = $operation->getParameters()->get($annotation->getName(), 'query');
|
||||
$parameter->setAllowEmptyValue($annotation->nullable && $annotation->allowBlank);
|
||||
|
||||
$parameter->setRequired(!$annotation->nullable && $annotation->strict);
|
||||
} else {
|
||||
$body = $operation->getParameters()->get('body', 'body')->getSchema();
|
||||
$body->setType('object');
|
||||
$parameter = $body->getProperties()->get($annotation->getName());
|
||||
|
||||
if (!$annotation->nullable && $annotation->strict) {
|
||||
$requiredParameters = $body->getRequired();
|
||||
$requiredParameters[] = $annotation->getName();
|
||||
|
||||
$body->setRequired(array_values(array_unique($requiredParameters)));
|
||||
}
|
||||
}
|
||||
|
||||
$parameter->setRequired(!$annotation->nullable && $annotation->strict);
|
||||
$parameter->setDefault($annotation->getDefault());
|
||||
if (null === $parameter->getType()) {
|
||||
$parameter->setType($annotation->map ? 'array' : 'string');
|
||||
|
@ -32,7 +32,7 @@ class DummyType extends AbstractType
|
||||
$builder->add('password', RepeatedType::class, [
|
||||
'type' => PasswordType::class,
|
||||
'first_name' => 'first_field',
|
||||
'required' => true
|
||||
'required' => true,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user