diff --git a/ModelDescriber/JMSModelDescriber.php b/ModelDescriber/JMSModelDescriber.php index d03c465..f5fc852 100644 --- a/ModelDescriber/JMSModelDescriber.php +++ b/ModelDescriber/JMSModelDescriber.php @@ -101,7 +101,8 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn } // read property options from Swagger Property annotation if it exists - $this->swaggerPropertyAnnotationReader->updateWithSwaggerPropertyAnnotation($item->reflection, $property); + if($item->reflection !== null) + $this->swaggerPropertyAnnotationReader->updateWithSwaggerPropertyAnnotation($item->reflection, $property); } } diff --git a/Tests/Functional/Controller/JMSController.php b/Tests/Functional/Controller/JMSController.php index a2452bc..a4399cc 100644 --- a/Tests/Functional/Controller/JMSController.php +++ b/Tests/Functional/Controller/JMSController.php @@ -13,6 +13,7 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Controller; use Nelmio\ApiDocBundle\Annotation\Model; use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSUser; +use Nelmio\ApiDocBundle\Tests\Functional\Entity\VirtualProperty; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Swagger\Annotations as SWG; @@ -29,4 +30,17 @@ class JMSController public function userAction() { } + + /** + * @Route("/api/yaml", methods={"GET"}) + * @SWG\Response( + * response=200, + * description="Success", + * @Model(type=VirtualProperty::class) + * ) + */ + public function yamlAction() + { + + } } diff --git a/Tests/Functional/Entity/VirtualProperty.php b/Tests/Functional/Entity/VirtualProperty.php new file mode 100644 index 0000000..7d7540b --- /dev/null +++ b/Tests/Functional/Entity/VirtualProperty.php @@ -0,0 +1,39 @@ +user = new User(); + $this->user->setEmail("dummy@test.com"); + } +} diff --git a/Tests/Functional/JMSFunctionalTest.php b/Tests/Functional/JMSFunctionalTest.php index 4995ad0..3e70951 100644 --- a/Tests/Functional/JMSFunctionalTest.php +++ b/Tests/Functional/JMSFunctionalTest.php @@ -49,6 +49,21 @@ class JMSFunctionalTest extends WebTestCase ], $this->getModel('JMSUser')->toArray()); } + public function testYamlConfig() + { + $this->assertEquals([ + 'type' => 'object', + 'properties' => [ + 'id' => [ + 'type' => 'integer', + ], + 'email' => [ + 'type' => 'string' + ], + ], + ], $this->getModel('VirtualProperty')->toArray()); + } + protected static function createKernel(array $options = array()) { return new TestKernel(true); diff --git a/composer.json b/composer.json index 354c5c1..5f1631a 100644 --- a/composer.json +++ b/composer.json @@ -38,12 +38,13 @@ "symfony/cache": "^3.1|^4.0", "symfony/phpunit-bridge": "^3.3", "sensio/framework-extra-bundle": "^3.0", + "symfony/stopwatch": "^2.8|^3.0|^4.0", "doctrine/annotations": "^1.2", "phpdocumentor/reflection-docblock": "^3.1", "api-platform/core": "^2.0.3", "friendsofsymfony/rest-bundle": "^2.0", - "jms/serializer-bundle": "^1.0|^2.0" + "jms/serializer-bundle": "^2.0" }, "suggest": { "phpdocumentor/reflection-docblock": "For parsing php docs.",