mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-10 11:39:25 +03:00
codestyle fixes
This commit is contained in:
parent
6e41a20e40
commit
b405b33ea2
@ -20,9 +20,6 @@ trait ModelRegistryAwareTrait
|
|||||||
*/
|
*/
|
||||||
private $modelRegistry;
|
private $modelRegistry;
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ModelRegistry $modelRegistry
|
|
||||||
*/
|
|
||||||
public function setModelRegistry(ModelRegistry $modelRegistry)
|
public function setModelRegistry(ModelRegistry $modelRegistry)
|
||||||
{
|
{
|
||||||
$this->modelRegistry = $modelRegistry;
|
$this->modelRegistry = $modelRegistry;
|
||||||
|
@ -116,11 +116,8 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if ($type->getInnerType() && ($formClass = get_class($type->getInnerType())) && !$this->isBuiltinType($formClass)) {
|
||||||
($formType = $type->getInnerType()) &&
|
//if form type is not builtin in Form component.
|
||||||
($formClass = get_class($formType)) &&
|
|
||||||
!$this->isBuiltinType($formClass) //don't check builtin types in Form component.
|
|
||||||
) {
|
|
||||||
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $formClass));
|
$model = new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $formClass));
|
||||||
$property->setRef($this->modelRegistry->register($model));
|
$property->setRef($this->modelRegistry->register($model));
|
||||||
break;
|
break;
|
||||||
@ -136,13 +133,8 @@ final class FormModelDescriber implements ModelDescriberInterface, ModelRegistry
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $type
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
*/
|
|
||||||
private function isBuiltinType(string $type): bool
|
private function isBuiltinType(string $type): bool
|
||||||
{
|
{
|
||||||
return strpos($type, 'Symfony\Component\Form\Extension\Core\Type') !== false;
|
return 0 === strpos($type, 'Symfony\Component\Form\Extension\Core\Type');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,9 +18,9 @@ use Nelmio\ApiDocBundle\Annotation\Operation;
|
|||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\Article;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Form\DummyType;
|
use Nelmio\ApiDocBundle\Tests\Functional\Form\DummyType;
|
||||||
|
use Nelmio\ApiDocBundle\Tests\Functional\Form\UserType;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Swagger\Annotations as SWG;
|
use Swagger\Annotations as SWG;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Form\UserType;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/api")
|
* @Route("/api")
|
||||||
|
@ -1,11 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the NelmioApiDocBundle package.
|
||||||
|
*
|
||||||
|
* (c) Nelmio
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Tests\Functional\Form;
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Form;
|
||||||
|
|
||||||
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\User;
|
|
||||||
|
|
||||||
class UserType extends AbstractType
|
class UserType extends AbstractType
|
||||||
{
|
{
|
||||||
@ -17,7 +26,7 @@ class UserType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setDefaults([
|
$resolver->setDefaults([
|
||||||
'data_class' => User::class
|
'data_class' => User::class,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -179,7 +179,7 @@ class FunctionalTest extends WebTestCase
|
|||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'type' => 'object',
|
'type' => 'object',
|
||||||
'properties' => [
|
'properties' => [
|
||||||
'dummy' => ['$ref' => '#/definitions/DummyType']
|
'dummy' => ['$ref' => '#/definitions/DummyType'],
|
||||||
],
|
],
|
||||||
'required' => ['dummy'],
|
'required' => ['dummy'],
|
||||||
], $this->getModel('UserType')->toArray());
|
], $this->getModel('UserType')->toArray());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user