mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
commit
1b6a1c2965
@ -29,10 +29,10 @@ final class ApiDocGenerator
|
|||||||
private $cacheItemPool;
|
private $cacheItemPool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param DescriberInterface[] $describers
|
* @param DescriberInterface[]|iterable $describers
|
||||||
* @param ModelDescriberInterface[] $modelDescribers
|
* @param ModelDescriberInterface[]|iterable $modelDescribers
|
||||||
*/
|
*/
|
||||||
public function __construct(array $describers, array $modelDescribers, CacheItemPoolInterface $cacheItemPool = null)
|
public function __construct($describers, $modelDescribers, CacheItemPoolInterface $cacheItemPool = null)
|
||||||
{
|
{
|
||||||
$this->describers = $describers;
|
$this->describers = $describers;
|
||||||
$this->modelDescribers = $modelDescribers;
|
$this->modelDescribers = $modelDescribers;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||||
|
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
<?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\DependencyInjection\Compiler;
|
|
||||||
|
|
||||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
||||||
use Symfony\Component\DependencyInjection\Reference;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trait that allows a generic method to find and sort service by priority option in the tag.
|
|
||||||
*
|
|
||||||
* @author Iltar van der Berg <kjarli@gmail.com>
|
|
||||||
*
|
|
||||||
* @internal extracted from Symfony, to keep sf 2.8 support.
|
|
||||||
*/
|
|
||||||
trait PriorityTaggedServiceTrait
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Finds all services with the given tag name and order them by their priority.
|
|
||||||
*
|
|
||||||
* The order of additions must be respected for services having the same priority,
|
|
||||||
* and knowing that the \SplPriorityQueue class does not respect the FIFO method,
|
|
||||||
* we should not use this class.
|
|
||||||
*
|
|
||||||
* @see https://bugs.php.net/bug.php?id=53710
|
|
||||||
* @see https://bugs.php.net/bug.php?id=60926
|
|
||||||
*
|
|
||||||
* @param string $tagName
|
|
||||||
* @param ContainerBuilder $container
|
|
||||||
*
|
|
||||||
* @return Reference[]
|
|
||||||
*/
|
|
||||||
private function findAndSortTaggedServices($tagName, ContainerBuilder $container)
|
|
||||||
{
|
|
||||||
$services = [];
|
|
||||||
foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $tags) {
|
|
||||||
foreach ($tags as $attributes) {
|
|
||||||
$priority = isset($attributes['priority']) ? $attributes['priority'] : 0;
|
|
||||||
$services[$priority][] = new Reference($serviceId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($services) {
|
|
||||||
krsort($services);
|
|
||||||
$services = call_user_func_array('array_merge', $services);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $services;
|
|
||||||
}
|
|
||||||
}
|
|
@ -28,11 +28,11 @@ final class RouteDescriber implements DescriberInterface, ModelRegistryAwareInte
|
|||||||
private $routeDescribers;
|
private $routeDescribers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param RouteCollection $routeCollection
|
* @param RouteCollection $routeCollection
|
||||||
* @param ControllerReflector $controllerReflector
|
* @param ControllerReflector $controllerReflector
|
||||||
* @param RouteDescriberInterface[] $routeDescribers
|
* @param RouteDescriberInterface[]|iterable $routeDescribers
|
||||||
*/
|
*/
|
||||||
public function __construct(RouteCollection $routeCollection, ControllerReflector $controllerReflector, array $routeDescribers)
|
public function __construct(RouteCollection $routeCollection, ControllerReflector $controllerReflector, $routeDescribers)
|
||||||
{
|
{
|
||||||
$this->routeCollection = $routeCollection;
|
$this->routeCollection = $routeCollection;
|
||||||
$this->controllerReflector = $controllerReflector;
|
$this->controllerReflector = $controllerReflector;
|
||||||
|
@ -30,11 +30,11 @@ final class ModelRegistry
|
|||||||
private $api;
|
private $api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ModelDescriberInterface[] $modelDescribers
|
* @param ModelDescriberInterface[]|iterable $modelDescribers
|
||||||
*
|
*
|
||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
public function __construct(array $modelDescribers, Swagger $api)
|
public function __construct($modelDescribers, Swagger $api)
|
||||||
{
|
{
|
||||||
$this->modelDescribers = $modelDescribers;
|
$this->modelDescribers = $modelDescribers;
|
||||||
$this->api = $api;
|
$this->api = $api;
|
||||||
|
@ -100,13 +100,12 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!array_key_exists($name, $model->getGroups()) || !is_array($model->getGroups()[$name])) {
|
if (!isset($model->getGroups()[$name]) || !is_array($model->getGroups()[$name])) {
|
||||||
$groups = $model->getGroups();
|
$groups = $model->getGroups();
|
||||||
} else {
|
} else {
|
||||||
$groups = $model->getGroups()[$name];
|
$groups = $model->getGroups()[$name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$property->setRef(
|
$property->setRef(
|
||||||
$this->modelRegistry->register(new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $type), $groups))
|
$this->modelRegistry->register(new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $type), $groups))
|
||||||
);
|
);
|
||||||
|
@ -12,8 +12,8 @@
|
|||||||
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
|
||||||
|
|
||||||
use Nelmio\ApiDocBundle\Annotation\Model;
|
use Nelmio\ApiDocBundle\Annotation\Model;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSUser;
|
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex;
|
||||||
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSUser;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\VirtualProperty;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\VirtualProperty;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||||
use Swagger\Annotations as SWG;
|
use Swagger\Annotations as SWG;
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Created by PhpStorm.
|
/*
|
||||||
* User: Frisks
|
* This file is part of the NelmioApiDocBundle package.
|
||||||
* Date: 2/12/2017
|
*
|
||||||
* Time: 1:18 PM
|
* (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\Entity;
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
||||||
@ -11,13 +14,10 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
|||||||
use JMS\Serializer\Annotation as Serializer;
|
use JMS\Serializer\Annotation as Serializer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class JMSComplex
|
|
||||||
* @package Nelmio\ApiDocBundle\Tests\Functional\Entity
|
|
||||||
* @Serializer\ExclusionPolicy("all")
|
* @Serializer\ExclusionPolicy("all")
|
||||||
*/
|
*/
|
||||||
class JMSComplex
|
class JMSComplex
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Serializer\Type("integer")
|
* @Serializer\Type("integer")
|
||||||
* @Serializer\Expose
|
* @Serializer\Expose
|
||||||
@ -25,7 +25,6 @@ class JMSComplex
|
|||||||
*/
|
*/
|
||||||
private $id;
|
private $id;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSUser")
|
* @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSUser")
|
||||||
* @Serializer\Expose
|
* @Serializer\Expose
|
||||||
@ -39,5 +38,4 @@ class JMSComplex
|
|||||||
* @Serializer\Groups({"list"})
|
* @Serializer\Groups({"list"})
|
||||||
*/
|
*/
|
||||||
private $name;
|
private $name;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class JMSFunctionalTest extends WebTestCase
|
|||||||
'properties' => [
|
'properties' => [
|
||||||
'id' => ['type' => 'integer'],
|
'id' => ['type' => 'integer'],
|
||||||
'user' => ['$ref' => '#/definitions/JMSUser2'],
|
'user' => ['$ref' => '#/definitions/JMSUser2'],
|
||||||
'name' => ['type' => 'string']
|
'name' => ['type' => 'string'],
|
||||||
],
|
],
|
||||||
], $this->getModel('JMSComplex')->toArray());
|
], $this->getModel('JMSComplex')->toArray());
|
||||||
|
|
||||||
|
@ -16,27 +16,26 @@
|
|||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.0",
|
"php": "^7.0",
|
||||||
"symfony/framework-bundle": "^3.2.5|^4.0",
|
"symfony/framework-bundle": "^3.4|^4.0",
|
||||||
"symfony/property-info": "^3.1|^4.0",
|
"symfony/property-info": "^3.4|^4.0",
|
||||||
"exsyst/swagger": "~0.3",
|
"exsyst/swagger": "~0.3",
|
||||||
"zircote/swagger-php": "^2.0.9"
|
"zircote/swagger-php": "^2.0.9"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"symfony/templating": "^2.8|^3.0|^4.0",
|
"symfony/templating": "^3.4|^4.0",
|
||||||
"symfony/twig-bundle": "^3.0|^4.0",
|
"symfony/twig-bundle": "^3.4|^4.0",
|
||||||
"symfony/asset": "^2.8|^3.0|^4.0",
|
"symfony/asset": "^3.4|^4.0",
|
||||||
"symfony/console": "^2.8|^3.0|^4.0",
|
"symfony/console": "^3.4|^4.0",
|
||||||
"symfony/config": "^2.8|^3.0|^4.0",
|
"symfony/config": "^3.4|^4.0",
|
||||||
"symfony/validator": "^2.8|^3.0|^4.0",
|
"symfony/validator": "^3.4|^4.0",
|
||||||
"symfony/property-access": "^2.8|^3.0|^4.0",
|
"symfony/property-access": "^3.4|^4.0",
|
||||||
"symfony/form": "^3.0.8|^4.0",
|
"symfony/form": "^3.4|^4.0",
|
||||||
"symfony/dom-crawler": "^2.8|^3.0|^4.0",
|
"symfony/dom-crawler": "^3.4|^4.0",
|
||||||
"symfony/browser-kit": "^2.8|^3.0|^4.0",
|
"symfony/browser-kit": "^3.4|^4.0",
|
||||||
"symfony/cache": "^3.1|^4.0",
|
"symfony/cache": "^3.4|^4.0",
|
||||||
"symfony/phpunit-bridge": "^3.3",
|
"symfony/phpunit-bridge": "^3.4",
|
||||||
"symfony/stopwatch": "^2.8|^3.0|^4.0",
|
"symfony/stopwatch": "^3.4|^4.0",
|
||||||
"sensio/framework-extra-bundle": "^3.0",
|
"sensio/framework-extra-bundle": "^3.0",
|
||||||
"symfony/stopwatch": "^2.8|^3.0|^4.0",
|
|
||||||
"doctrine/annotations": "^1.2",
|
"doctrine/annotations": "^1.2",
|
||||||
|
|
||||||
"phpdocumentor/reflection-docblock": "^3.1",
|
"phpdocumentor/reflection-docblock": "^3.1",
|
||||||
@ -56,7 +55,7 @@
|
|||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.0.x-dev"
|
"dev-master": "3.1.x-dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user