mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 15:51:48 +03:00
Added the support of form types defined as services
This commit is contained in:
parent
c127a1c4bf
commit
fd8ee2679a
@ -120,7 +120,7 @@ abstract class AbstractFormatter implements FormatterInterface
|
||||
$data['requirements'] = $requirements;
|
||||
|
||||
if (null !== $formType = $apiDoc->getFormType()) {
|
||||
$data['parameters'] = $this->parser->parse(new $formType());
|
||||
$data['parameters'] = $this->parser->parse($formType);
|
||||
|
||||
if ('PUT' === $method) {
|
||||
// All parameters are optional with PUT (update)
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
namespace Nelmio\ApiDocBundle\Parser;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilder;
|
||||
use Symfony\Component\Form\FormFactoryInterface;
|
||||
|
||||
@ -47,11 +46,14 @@ class FormTypeParser
|
||||
* - required
|
||||
* - description
|
||||
*
|
||||
* @param AbstractType $type
|
||||
* @param string|\Symfony\Component\Form\FormTypeInterface $type
|
||||
* @return array
|
||||
*/
|
||||
public function parse(AbstractType $type)
|
||||
public function parse($type)
|
||||
{
|
||||
if (is_string($type) && class_exists($type)) {
|
||||
$type = new $type();
|
||||
}
|
||||
$form = $this->formFactory->create($type);
|
||||
|
||||
$parameters = array();
|
||||
|
@ -95,7 +95,8 @@ The following properties are available:
|
||||
|
||||
* `filters`: an array of filters;
|
||||
|
||||
* `formType`: the Form Type associated to the method, useful for POST|PUT methods.
|
||||
* `formType`: the Form Type associated to the method, useful for POST|PUT methods, either as FQCN or
|
||||
as form type (if it is registered in the form factory in the container)
|
||||
|
||||
Each _filter_ has to define a `name` parameter, but other parameters are free. Filters are often optional
|
||||
parameters, and you can document them as you want, but keep in mind to be consistent for the whole documentation.
|
||||
|
Loading…
x
Reference in New Issue
Block a user