diff --git a/DependencyInjection/NelmioApiDocExtension.php b/DependencyInjection/NelmioApiDocExtension.php index abf129a..1ecae53 100644 --- a/DependencyInjection/NelmioApiDocExtension.php +++ b/DependencyInjection/NelmioApiDocExtension.php @@ -35,6 +35,6 @@ class NelmioApiDocExtension extends Extension $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('formatters.xml'); $loader->load('request_listener.xml'); - $loader->load('services.xml'); + $loader->load('services.xml'); } } diff --git a/DependencyInjection/RegisterJmsParserPass.php b/DependencyInjection/RegisterJmsParserPass.php index 133610f..81af794 100644 --- a/DependencyInjection/RegisterJmsParserPass.php +++ b/DependencyInjection/RegisterJmsParserPass.php @@ -4,9 +4,7 @@ namespace Nelmio\ApiDocBundle\DependencyInjection; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; -use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\Config\Definition\Processor; use Symfony\Component\Config\FileLocator; class RegisterJmsParserPass implements CompilerPassInterface @@ -14,7 +12,7 @@ class RegisterJmsParserPass implements CompilerPassInterface public function process(ContainerBuilder $container) { $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - + //JMS may or may not be installed, if it is, load that config as well try { if ($serializer = $container->findDefinition('serializer')) { diff --git a/Parser/JmsMetadataParser.php b/Parser/JmsMetadataParser.php index d9cb507..996c8db 100644 --- a/Parser/JmsMetadataParser.php +++ b/Parser/JmsMetadataParser.php @@ -18,7 +18,7 @@ use Metadata\MetadataFactoryInterface; */ class JmsMetadataParser implements ParserInterface { - + /** * Constructor, requires JMS Metadata factory */ @@ -26,19 +26,19 @@ class JmsMetadataParser implements ParserInterface { $this->factory = $factory; } - + /** * {@inheritdoc} */ public function supports($input) { - if($meta = $this->factory->getMetadataForClass($input)) { + if ($meta = $this->factory->getMetadataForClass($input)) { return true; } - + return false; } - + /** * {@inheritdoc} */ @@ -46,20 +46,20 @@ class JmsMetadataParser implements ParserInterface { $meta = $this->factory->getMetadataForClass($input); - if(is_null($meta)) { + if (is_null($meta)) { throw new \InvalidArgumentException(sprintf("No metadata found for class %s", $input)); } - + $params = array(); - + //iterate over property metadata foreach ($meta->propertyMetadata as $item) { - + if (!is_null($item->type)) { $name = isset($item->serializedName) ? $item->serializedName : $item->name; - + //TODO: check for nested type - + $params[$name] = array( 'dataType' => $item->type, 'required' => false, //TODO: can't think of a good way to specify this one, JMS doesn't have a setting for this @@ -68,17 +68,16 @@ class JmsMetadataParser implements ParserInterface ); } } - + return $params; } - + protected function getDescription($className, $propertyName) { $description = "No description."; //TODO: regex comment to get description - or move doc comment parsing functionality from `ApiDocExtractor` to a new location //in order to reuse it here - return $description; } diff --git a/Tests/Fixtures/Controller/TestController.php b/Tests/Fixtures/Controller/TestController.php index e01189d..16c8e04 100644 --- a/Tests/Fixtures/Controller/TestController.php +++ b/Tests/Fixtures/Controller/TestController.php @@ -90,7 +90,7 @@ class TestController public function zActionWithQueryParamAction() { } - + /** * @ApiDoc( * description="Testing JMS", diff --git a/Tests/Fixtures/Model/JmsTest.php b/Tests/Fixtures/Model/JmsTest.php index 343d936..ff44443 100644 --- a/Tests/Fixtures/Model/JmsTest.php +++ b/Tests/Fixtures/Model/JmsTest.php @@ -7,27 +7,27 @@ use JMS\SerializerBundle\Annotation as JMS; class JmsTest { public $nothing; - - /** - * @JMS\Type("string"); - */ - public $foo; - + + /** + * @JMS\Type("string"); + */ + public $foo; + /** * @JMS\Type("DateTime"); * @JMS\ReadOnly */ public $bar; - + /** * @JMS\Type("double"); * @JMS\SerializedName("number"); */ public $baz; - + /** * @JMS\Type("array"); */ public $arr; - + } diff --git a/Tests/Fixtures/app/config/default.yml b/Tests/Fixtures/app/config/default.yml index a046f02..6c822c9 100644 --- a/Tests/Fixtures/app/config/default.yml +++ b/Tests/Fixtures/app/config/default.yml @@ -55,4 +55,3 @@ jms_serializer: # class: My\FooBundle\Entity\User # expected path: @MyFooBundle/Resources/config/serializer/Entity.User.(yml|xml|php) auto_detection: true - diff --git a/Tests/Fixtures/app/config/routing.yml b/Tests/Fixtures/app/config/routing.yml index f451e2b..cad9f93 100644 --- a/Tests/Fixtures/app/config/routing.yml +++ b/Tests/Fixtures/app/config/routing.yml @@ -69,4 +69,3 @@ test_service_route_4: NelmioApiDocBundle: resource: "@NelmioApiDocBundle/Resources/config/routing.yml" prefix: / - \ No newline at end of file