mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 07:41:43 +03:00
cs
This commit is contained in:
parent
e23a7d7d66
commit
0a1cef77ad
@ -66,6 +66,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand
|
|||||||
if ($input->getOption('list-only')) {
|
if ($input->getOption('list-only')) {
|
||||||
$data = $this->getResourceList($apiDocs, $output);
|
$data = $this->getResourceList($apiDocs, $output);
|
||||||
$this->dump($data, null, $input, $output);
|
$this->dump($data, null, $input, $output);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +76,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand
|
|||||||
throw new \InvalidArgumentException(sprintf('Resource "%s" does not exist.', $resource));
|
throw new \InvalidArgumentException(sprintf('Resource "%s" does not exist.', $resource));
|
||||||
}
|
}
|
||||||
$this->dump($data, $resource, $input, $output);
|
$this->dump($data, $resource, $input, $output);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,6 +112,7 @@ class SwaggerDumpCommand extends ContainerAwareCommand
|
|||||||
|
|
||||||
if (!$destination) {
|
if (!$destination) {
|
||||||
$output->writeln($content);
|
$output->writeln($content);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class DataTypes
|
|||||||
/**
|
/**
|
||||||
* Returns true if the supplied `actualType` value is considered a primitive type. Returns false, otherwise.
|
* Returns true if the supplied `actualType` value is considered a primitive type. Returns false, otherwise.
|
||||||
*
|
*
|
||||||
* @param string $type
|
* @param string $type
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function isPrimitive($type)
|
public static function isPrimitive($type)
|
||||||
|
@ -11,15 +11,8 @@
|
|||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\DependencyInjection;
|
namespace Nelmio\ApiDocBundle\DependencyInjection;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Alias;
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
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.
|
* Compiler pass that configures the SwaggerFormatter instance.
|
||||||
@ -55,4 +48,4 @@ class SwaggerConfigCompilerPass implements CompilerPassInterface
|
|||||||
$formatter->addMethodCall('setAuthenticationConfig', array($authentication));
|
$formatter->addMethodCall('setAuthenticationConfig', array($authentication));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -521,8 +521,8 @@ class ApiDocExtractor
|
|||||||
/**
|
/**
|
||||||
* Creates a human-readable version of the `actualType`. `subType` is taken into account.
|
* Creates a human-readable version of the `actualType`. `subType` is taken into account.
|
||||||
*
|
*
|
||||||
* @param string $actualType
|
* @param string $actualType
|
||||||
* @param string $subType
|
* @param string $subType
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function generateHumanReadableType($actualType, $subType)
|
protected function generateHumanReadableType($actualType, $subType)
|
||||||
@ -531,6 +531,7 @@ class ApiDocExtractor
|
|||||||
|
|
||||||
if (class_exists($subType)) {
|
if (class_exists($subType)) {
|
||||||
$parts = explode('\\', $subType);
|
$parts = explode('\\', $subType);
|
||||||
|
|
||||||
return sprintf('object (%s)', end($parts));
|
return sprintf('object (%s)', end($parts));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -545,6 +546,7 @@ class ApiDocExtractor
|
|||||||
|
|
||||||
if (class_exists($subType)) {
|
if (class_exists($subType)) {
|
||||||
$parts = explode('\\', $subType);
|
$parts = explode('\\', $subType);
|
||||||
|
|
||||||
return sprintf('array of objects (%s)', end($parts));
|
return sprintf('array of objects (%s)', end($parts));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ use Nelmio\ApiDocBundle\Util\DocCommentExtractor;
|
|||||||
use Symfony\Component\Config\ConfigCache;
|
use Symfony\Component\Config\ConfigCache;
|
||||||
use Symfony\Component\Config\Resource\FileResource;
|
use Symfony\Component\Config\Resource\FileResource;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
|
||||||
use Symfony\Component\Routing\RouterInterface;
|
use Symfony\Component\Routing\RouterInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,11 +64,11 @@ class CachingApiDocExtractor extends ApiDocExtractor
|
|||||||
|
|
||||||
$data = parent::all();
|
$data = parent::all();
|
||||||
$this->cache->write(serialize($data), $resources);
|
$this->cache->write(serialize($data), $resources);
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
return unserialize(file_get_contents($this->cacheFile));
|
return unserialize(file_get_contents($this->cacheFile));
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ interface HandlerInterface
|
|||||||
* Parse route parameters in order to populate ApiDoc.
|
* Parse route parameters in order to populate ApiDoc.
|
||||||
*
|
*
|
||||||
* @param \Nelmio\ApiDocBundle\Annotation\ApiDoc $annotation
|
* @param \Nelmio\ApiDocBundle\Annotation\ApiDoc $annotation
|
||||||
* @param array $annotations
|
* @param array $annotations
|
||||||
* @param \Symfony\Component\Routing\Route $route
|
* @param \Symfony\Component\Routing\Route $route
|
||||||
* @param \ReflectionMethod $method
|
* @param \ReflectionMethod $method
|
||||||
*/
|
*/
|
||||||
|
@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Formatter;
|
namespace Nelmio\ApiDocBundle\Formatter;
|
||||||
|
|
||||||
|
|
||||||
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
|
||||||
@ -33,7 +32,7 @@ class RequestAwareSwaggerFormatter implements FormatterInterface
|
|||||||
protected $formatter;
|
protected $formatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param SwaggerFormatter $formatter
|
* @param SwaggerFormatter $formatter
|
||||||
*/
|
*/
|
||||||
public function __construct(Request $request, SwaggerFormatter $formatter)
|
public function __construct(Request $request, SwaggerFormatter $formatter)
|
||||||
@ -45,8 +44,8 @@ class RequestAwareSwaggerFormatter implements FormatterInterface
|
|||||||
/**
|
/**
|
||||||
* Format a collection of documentation data.
|
* Format a collection of documentation data.
|
||||||
*
|
*
|
||||||
* @param array $collection
|
* @param array $collection
|
||||||
* @param null $resource
|
* @param null $resource
|
||||||
* @internal param $array [ApiDoc] $collection
|
* @internal param $array [ApiDoc] $collection
|
||||||
* @return string|array
|
* @return string|array
|
||||||
*/
|
*/
|
||||||
@ -71,4 +70,4 @@ class RequestAwareSwaggerFormatter implements FormatterInterface
|
|||||||
{
|
{
|
||||||
return $this->formatter->formatOne($annotation);
|
return $this->formatter->formatOne($annotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
|||||||
use Nelmio\ApiDocBundle\DataTypes;
|
use Nelmio\ApiDocBundle\DataTypes;
|
||||||
use Nelmio\ApiDocBundle\Swagger\ModelRegistry;
|
use Nelmio\ApiDocBundle\Swagger\ModelRegistry;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
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:
|
* 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.
|
* If resource is provided, an API declaration for that resource is produced. Otherwise, a resource listing is returned.
|
||||||
*
|
*
|
||||||
* @param array|ApiDoc[] $collection
|
* @param array|ApiDoc[] $collection
|
||||||
* @param null|string $resource
|
* @param null|string $resource
|
||||||
* @return string|array
|
* @return string|array
|
||||||
*/
|
*/
|
||||||
public function format(array $collection, $resource = null)
|
public function format(array $collection, $resource = null)
|
||||||
@ -95,7 +93,7 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
/**
|
/**
|
||||||
* Formats the collection into Swagger-compliant output.
|
* Formats the collection into Swagger-compliant output.
|
||||||
*
|
*
|
||||||
* @param array $collection
|
* @param array $collection
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function produceResourceListing(array $collection)
|
public function produceResourceListing(array $collection)
|
||||||
@ -167,8 +165,8 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
/**
|
/**
|
||||||
* Format documentation data for one route.
|
* Format documentation data for one route.
|
||||||
*
|
*
|
||||||
* @param ApiDoc $annotation
|
* @param ApiDoc $annotation
|
||||||
* return string|array
|
* return string|array
|
||||||
* @throws \BadMethodCallException
|
* @throws \BadMethodCallException
|
||||||
*/
|
*/
|
||||||
public function formatOne(ApiDoc $annotation)
|
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.
|
* Formats collection to produce a Swagger-compliant API declaration for the given resource.
|
||||||
*
|
*
|
||||||
* @param array $collection
|
* @param array $collection
|
||||||
* @param string $resource
|
* @param string $resource
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function produceApiDeclaration(array $collection, $resource)
|
protected function produceApiDeclaration(array $collection, $resource)
|
||||||
@ -202,7 +200,6 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
|
|
||||||
$apiBag = array();
|
$apiBag = array();
|
||||||
|
|
||||||
|
|
||||||
foreach ($collection as $item) {
|
foreach ($collection as $item) {
|
||||||
|
|
||||||
/** @var $apiDoc ApiDoc */
|
/** @var $apiDoc ApiDoc */
|
||||||
@ -373,6 +370,7 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
$path = preg_replace('/({.*?})/', '', $path);
|
$path = preg_replace('/({.*?})/', '', $path);
|
||||||
$path = trim(preg_replace('/[^0-9a-zA-Z]/', '-', $path), '-');
|
$path = trim(preg_replace('/[^0-9a-zA-Z]/', '-', $path), '-');
|
||||||
$path = preg_replace('/-+/', '-', $path);
|
$path = preg_replace('/-+/', '-', $path);
|
||||||
|
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -387,7 +385,7 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
/**
|
/**
|
||||||
* Formats query parameters to Swagger-compliant form.
|
* Formats query parameters to Swagger-compliant form.
|
||||||
*
|
*
|
||||||
* @param array $input
|
* @param array $input
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function deriveQueryParameters(array $input)
|
protected function deriveQueryParameters(array $input)
|
||||||
@ -580,6 +578,7 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
|
|
||||||
$pattern = sprintf('#^%s#', preg_quote($this->basePath));
|
$pattern = sprintf('#^%s#', preg_quote($this->basePath));
|
||||||
$subPath = preg_replace($pattern, '', $path);
|
$subPath = preg_replace($pattern, '', $path);
|
||||||
|
|
||||||
return $subPath;
|
return $subPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -594,6 +593,7 @@ class SwaggerFormatter implements FormatterInterface
|
|||||||
{
|
{
|
||||||
$resource = preg_replace('#/^#', '', $resource);
|
$resource = preg_replace('#/^#', '', $resource);
|
||||||
$resource = $this->normalizeResourcePath($resource);
|
$resource = $this->normalizeResourcePath($resource);
|
||||||
|
|
||||||
return sprintf('%s_%s', strtolower($method), $resource);
|
return sprintf('%s_%s', strtolower($method), $resource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ class CollectionParser implements ParserInterface, PostParserInterface
|
|||||||
/**
|
/**
|
||||||
* Return true/false whether this class supports parsing the given class.
|
* 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
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
@ -47,7 +47,7 @@ class CollectionParser implements ParserInterface, PostParserInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array|string $item The string type of input to parse.
|
* @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
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -74,4 +74,4 @@ class CollectionParser implements ParserInterface, PostParserInterface
|
|||||||
|
|
||||||
return $parameters;
|
return $parameters;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ class FormErrorsParser implements ParserInterface, PostParserInterface
|
|||||||
/**
|
/**
|
||||||
* Return true/false whether this class supports parsing the given class.
|
* 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
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
@ -258,7 +258,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<input type="hidden" name="header_method" value="{{ methods|join }}" />
|
<input type="hidden" name="header_method" value="{{ methods|join }}" />
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<legend>Headers</legend>
|
<legend>Headers</legend>
|
||||||
|
|
||||||
{% if acceptType %}
|
{% if acceptType %}
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
namespace NelmioApiDocBundle\Tests\Controller;
|
namespace NelmioApiDocBundle\Tests\Controller;
|
||||||
use Nelmio\ApiDocBundle\Tests\WebTestCase;
|
use Nelmio\ApiDocBundle\Tests\WebTestCase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class ApiDocControllerTest
|
* Class ApiDocControllerTest
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Tests\Extractor;
|
namespace Nelmio\ApiDocBundle\Tests\Extractor;
|
||||||
|
|
||||||
class CollectionDirectiveTest extends \PHPUnit_Framework_TestCase
|
class CollectionDirectiveTest extends \PHPUnit_Framework_TestCase
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Tests\Extractor;
|
namespace Nelmio\ApiDocBundle\Tests\Extractor;
|
||||||
|
|
||||||
use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;
|
use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
namespace Nelmio\ApiDocBundle\Tests\Fixtures\Controller;
|
namespace Nelmio\ApiDocBundle\Tests\Fixtures\Controller;
|
||||||
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||||
|
|
||||||
class ResourceController
|
class ResourceController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ApiDoc(
|
* @ApiDoc(
|
||||||
@ -87,4 +87,4 @@ class ResourceController
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -238,4 +238,4 @@ test_route_25:
|
|||||||
pattern: /with-link
|
pattern: /with-link
|
||||||
defaults: { _controller: NelmioApiDocTestBundle:Test:withLinkAction }
|
defaults: { _controller: NelmioApiDocTestBundle:Test:withLinkAction }
|
||||||
requirements:
|
requirements:
|
||||||
_method: GET
|
_method: GET
|
||||||
|
@ -2,12 +2,10 @@
|
|||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Tests\Formatter;
|
namespace Nelmio\ApiDocBundle\Tests\Formatter;
|
||||||
|
|
||||||
|
|
||||||
use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;
|
use Nelmio\ApiDocBundle\Extractor\ApiDocExtractor;
|
||||||
use Nelmio\ApiDocBundle\Formatter\SwaggerFormatter;
|
use Nelmio\ApiDocBundle\Formatter\SwaggerFormatter;
|
||||||
use Nelmio\ApiDocBundle\Tests\WebTestCase;
|
use Nelmio\ApiDocBundle\Tests\WebTestCase;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SwaggerFormatterTest
|
* Class SwaggerFormatterTest
|
||||||
*
|
*
|
||||||
@ -36,7 +34,6 @@ class SwaggerFormatterTest extends WebTestCase
|
|||||||
$this->formatter = $container->get('nelmio_api_doc.formatter.swagger_formatter');
|
$this->formatter = $container->get('nelmio_api_doc.formatter.swagger_formatter');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testResourceListing()
|
public function testResourceListing()
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -99,7 +96,6 @@ class SwaggerFormatterTest extends WebTestCase
|
|||||||
|
|
||||||
$this->assertEquals($expected, $actual);
|
$this->assertEquals($expected, $actual);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -988,4 +984,4 @@ With multiple lines.',
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user