In my symfony2 project, I installed FOSRestBundle and NelmioApiDocBundle to create an api.
I have a strange behavior with my POST route: when I add the “annotation” annotation property, the Nelmio package generates an additional parameter in addition to my form fields. This optional parameter is the form itself.
Screen:

I tried to debug the moment when Nelmio parses my route annotations:

We can notice that the property is parametersset.
Here are the annotations of my post action method:
public function postPunchlineAction(Request $request)
And this is my FormType:
<?php
namespace Punchline\BackendBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class PunchlineType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('content', 'text')
->add('author', 'author_selector')
->add('single', 'single_selector')
;
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Punchline\BackendBundle\Entity\Punchline'
));
}
public function getName()
{
return 'punchline';
}
}
From the NelmioApiDocBundle Documentation :
, , , .
, ... , .