This commit is contained in:
William Durand 2015-03-06 11:19:08 +01:00
parent e23a7d7d66
commit 0a1cef77ad
No known key found for this signature in database
GPG Key ID: A509BCF1C1274F3B
17 changed files with 37 additions and 48 deletions

View File

@ -66,6 +66,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand
if ($input->getOption('list-only')) {
$data = $this->getResourceList($apiDocs, $output);
$this->dump($data, null, $input, $output);
return;
}
@ -75,6 +76,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand
throw new \InvalidArgumentException(sprintf('Resource "%s" does not exist.', $resource));
}
$this->dump($data, $resource, $input, $output);
return;
}
@ -110,6 +112,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand
if (!$destination) {
$output->writeln($content);
return;
}

View File

@ -43,7 +43,7 @@ class DataTypes
/**
* Returns true if the supplied `actualType` value is considered a primitive type. Returns false, otherwise.
*
* @param string $type
* @param string $type
* @return bool
*/
public static function isPrimitive($type)

View File

@ -11,15 +11,8 @@
namespace Nelmio\ApiDocBundle\DependencyInjection;
use Symfony\Component\DependencyInjection\Alias;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Parameter;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Filesystem\Exception\IOException;
use Symfony\Component\Filesystem\Filesystem;
/**
* Compiler pass that configures the SwaggerFormatter instance.

View File

@ -521,8 +521,8 @@ class ApiDocExtractor
/**
* Creates a human-readable version of the `actualType`. `subType` is taken into account.
*
* @param string $actualType
* @param string $subType
* @param string $actualType
* @param string $subType
* @return string
*/
protected function generateHumanReadableType($actualType, $subType)
@ -531,6 +531,7 @@ class ApiDocExtractor
if (class_exists($subType)) {
$parts = explode('\\', $subType);
return sprintf('object (%s)', end($parts));
}
@ -545,6 +546,7 @@ class ApiDocExtractor
if (class_exists($subType)) {
$parts = explode('\\', $subType);
return sprintf('array of objects (%s)', end($parts));
}

View File

@ -16,7 +16,6 @@ use Nelmio\ApiDocBundle\Util\DocCommentExtractor;
use Symfony\Component\Config\ConfigCache;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Routing\RouterInterface;
/**

View File

@ -20,7 +20,7 @@ interface HandlerInterface
* Parse route parameters in order to populate ApiDoc.
*
* @param \Nelmio\ApiDocBundle\Annotation\ApiDoc $annotation
* @param array $annotations
* @param array $annotations
* @param \Symfony\Component\Routing\Route $route
* @param \ReflectionMethod $method
*/

View File

@ -11,7 +11,6 @@
namespace Nelmio\ApiDocBundle\Formatter;
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Component\HttpFoundation\Request;
@ -33,7 +32,7 @@ class RequestAwareSwaggerFormatter implements FormatterInterface
protected $formatter;
/**
* @param Request $request
* @param Request $request
* @param SwaggerFormatter $formatter
*/
public function __construct(Request $request, SwaggerFormatter $formatter)
@ -45,8 +44,8 @@ class RequestAwareSwaggerFormatter implements FormatterInterface
/**
* Format a collection of documentation data.
*
* @param array $collection
* @param null $resource
* @param array $collection
* @param null $resource
* @internal param $array [ApiDoc] $collection
* @return string|array
*/

View File

@ -15,8 +15,6 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Nelmio\ApiDocBundle\DataTypes;
use Nelmio\ApiDocBundle\Swagger\ModelRegistry;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Router;
use Symfony\Component\Routing\RouterInterface;
/**
* Produces Swagger-compliant resource lists and API declarations as defined here:
@ -79,8 +77,8 @@ class SwaggerFormatter implements FormatterInterface
*
* If resource is provided, an API declaration for that resource is produced. Otherwise, a resource listing is returned.
*
* @param array|ApiDoc[] $collection
* @param null|string $resource
* @param array|ApiDoc[] $collection
* @param null|string $resource
* @return string|array
*/
public function format(array $collection, $resource = null)
@ -95,7 +93,7 @@ class SwaggerFormatter implements FormatterInterface
/**
* Formats the collection into Swagger-compliant output.
*
* @param array $collection
* @param array $collection
* @return array
*/
public function produceResourceListing(array $collection)
@ -167,8 +165,8 @@ class SwaggerFormatter implements FormatterInterface
/**
* Format documentation data for one route.
*
* @param ApiDoc $annotation
* return string|array
* @param ApiDoc $annotation
* return string|array
* @throws \BadMethodCallException
*/
public function formatOne(ApiDoc $annotation)
@ -179,8 +177,8 @@ class SwaggerFormatter implements FormatterInterface
/**
* Formats collection to produce a Swagger-compliant API declaration for the given resource.
*
* @param array $collection
* @param string $resource
* @param array $collection
* @param string $resource
* @return array
*/
protected function produceApiDeclaration(array $collection, $resource)
@ -202,7 +200,6 @@ class SwaggerFormatter implements FormatterInterface
$apiBag = array();
foreach ($collection as $item) {
/** @var $apiDoc ApiDoc */
@ -373,6 +370,7 @@ class SwaggerFormatter implements FormatterInterface
$path = preg_replace('/({.*?})/', '', $path);
$path = trim(preg_replace('/[^0-9a-zA-Z]/', '-', $path), '-');
$path = preg_replace('/-+/', '-', $path);
return $path;
}
@ -387,7 +385,7 @@ class SwaggerFormatter implements FormatterInterface
/**
* Formats query parameters to Swagger-compliant form.
*
* @param array $input
* @param array $input
* @return array
*/
protected function deriveQueryParameters(array $input)
@ -580,6 +578,7 @@ class SwaggerFormatter implements FormatterInterface
$pattern = sprintf('#^%s#', preg_quote($this->basePath));
$subPath = preg_replace($pattern, '', $path);
return $subPath;
}
@ -594,6 +593,7 @@ class SwaggerFormatter implements FormatterInterface
{
$resource = preg_replace('#/^#', '', $resource);
$resource = $this->normalizeResourcePath($resource);
return sprintf('%s_%s', strtolower($method), $resource);
}
}

View File

@ -24,7 +24,7 @@ class CollectionParser implements ParserInterface, PostParserInterface
/**
* Return true/false whether this class supports parsing the given class.
*
* @param array $item containing the following fields: class, groups. Of which groups is optional
* @param array $item containing the following fields: class, groups. Of which groups is optional
*
* @return boolean
*/
@ -47,7 +47,7 @@ class CollectionParser implements ParserInterface, PostParserInterface
/**
* @param array|string $item The string type of input to parse.
* @param array $parameters The previously-parsed parameters array.
* @param array $parameters The previously-parsed parameters array.
*
* @return array
*/

View File

@ -21,7 +21,7 @@ class FormErrorsParser implements ParserInterface, PostParserInterface
/**
* Return true/false whether this class supports parsing the given class.
*
* @param array $item containing the following fields: class, groups. Of which groups is optional
* @param array $item containing the following fields: class, groups. Of which groups is optional
*
* @return boolean
*/

View File

@ -9,7 +9,6 @@
namespace NelmioApiDocBundle\Tests\Controller;
use Nelmio\ApiDocBundle\Tests\WebTestCase;
/**
* Class ApiDocControllerTest
*

View File

@ -1,6 +1,5 @@
<?php
namespace Nelmio\ApiDocBundle\Tests\Extractor;
class CollectionDirectiveTest extends \PHPUnit_Framework_TestCase

View File

@ -1,6 +1,5 @@
<?php
namespace Nelmio\ApiDocBundle\Tests\Extractor;
use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;

View File

@ -2,12 +2,10 @@
namespace Nelmio\ApiDocBundle\Tests\Formatter;
use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;
use Nelmio\ApiDocBundle\Formatter\SwaggerFormatter;
use Nelmio\ApiDocBundle\Tests\WebTestCase;
/**
* Class SwaggerFormatterTest
*
@ -36,7 +34,6 @@ class SwaggerFormatterTest extends WebTestCase
$this->formatter = $container->get('nelmio_api_doc.formatter.swagger_formatter');
}
public function testResourceListing()
{
@ -99,7 +96,6 @@ class SwaggerFormatterTest extends WebTestCase
$this->assertEquals($expected, $actual);
}
/**