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;
|
||||
|
||||
/**
|
||||
* @param DescriberInterface[] $describers
|
||||
* @param ModelDescriberInterface[] $modelDescribers
|
||||
* @param DescriberInterface[]|iterable $describers
|
||||
* @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->modelDescribers = $modelDescribers;
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace Nelmio\ApiDocBundle\DependencyInjection\Compiler;
|
||||
|
||||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
|
||||
use Symfony\Component\DependencyInjection\Compiler\PriorityTaggedServiceTrait;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @param RouteCollection $routeCollection
|
||||
* @param ControllerReflector $controllerReflector
|
||||
* @param RouteDescriberInterface[] $routeDescribers
|
||||
* @param RouteCollection $routeCollection
|
||||
* @param ControllerReflector $controllerReflector
|
||||
* @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->controllerReflector = $controllerReflector;
|
||||
|
@ -30,11 +30,11 @@ final class ModelRegistry
|
||||
private $api;
|
||||
|
||||
/**
|
||||
* @param ModelDescriberInterface[] $modelDescribers
|
||||
* @param ModelDescriberInterface[]|iterable $modelDescribers
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function __construct(array $modelDescribers, Swagger $api)
|
||||
public function __construct($modelDescribers, Swagger $api)
|
||||
{
|
||||
$this->modelDescribers = $modelDescribers;
|
||||
$this->api = $api;
|
||||
|
@ -100,13 +100,12 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
|
||||
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();
|
||||
} else {
|
||||
$groups = $model->getGroups()[$name];
|
||||
}
|
||||
|
||||
|
||||
$property->setRef(
|
||||
$this->modelRegistry->register(new Model(new Type(Type::BUILTIN_TYPE_OBJECT, false, $type), $groups))
|
||||
);
|
||||
|
@ -12,8 +12,8 @@
|
||||
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
|
||||
|
||||
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\JMSUser;
|
||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\VirtualProperty;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Swagger\Annotations as SWG;
|
||||
|
@ -1,9 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by PhpStorm.
|
||||
* User: Frisks
|
||||
* Date: 2/12/2017
|
||||
* Time: 1:18 PM
|
||||
|
||||
/*
|
||||
* 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\Tests\Functional\Entity;
|
||||
@ -11,13 +14,10 @@ namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
||||
use JMS\Serializer\Annotation as Serializer;
|
||||
|
||||
/**
|
||||
* Class JMSComplex
|
||||
* @package Nelmio\ApiDocBundle\Tests\Functional\Entity
|
||||
* @Serializer\ExclusionPolicy("all")
|
||||
*/
|
||||
class JMSComplex
|
||||
{
|
||||
|
||||
/**
|
||||
* @Serializer\Type("integer")
|
||||
* @Serializer\Expose
|
||||
@ -25,7 +25,6 @@ class JMSComplex
|
||||
*/
|
||||
private $id;
|
||||
|
||||
|
||||
/**
|
||||
* @Serializer\Type("Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSUser")
|
||||
* @Serializer\Expose
|
||||
@ -39,5 +38,4 @@ class JMSComplex
|
||||
* @Serializer\Groups({"list"})
|
||||
*/
|
||||
private $name;
|
||||
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class JMSFunctionalTest extends WebTestCase
|
||||
'properties' => [
|
||||
'id' => ['type' => 'integer'],
|
||||
'user' => ['$ref' => '#/definitions/JMSUser2'],
|
||||
'name' => ['type' => 'string']
|
||||
'name' => ['type' => 'string'],
|
||||
],
|
||||
], $this->getModel('JMSComplex')->toArray());
|
||||
|
||||
|
@ -16,27 +16,26 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "^7.0",
|
||||
"symfony/framework-bundle": "^3.2.5|^4.0",
|
||||
"symfony/property-info": "^3.1|^4.0",
|
||||
"symfony/framework-bundle": "^3.4|^4.0",
|
||||
"symfony/property-info": "^3.4|^4.0",
|
||||
"exsyst/swagger": "~0.3",
|
||||
"zircote/swagger-php": "^2.0.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/templating": "^2.8|^3.0|^4.0",
|
||||
"symfony/twig-bundle": "^3.0|^4.0",
|
||||
"symfony/asset": "^2.8|^3.0|^4.0",
|
||||
"symfony/console": "^2.8|^3.0|^4.0",
|
||||
"symfony/config": "^2.8|^3.0|^4.0",
|
||||
"symfony/validator": "^2.8|^3.0|^4.0",
|
||||
"symfony/property-access": "^2.8|^3.0|^4.0",
|
||||
"symfony/form": "^3.0.8|^4.0",
|
||||
"symfony/dom-crawler": "^2.8|^3.0|^4.0",
|
||||
"symfony/browser-kit": "^2.8|^3.0|^4.0",
|
||||
"symfony/cache": "^3.1|^4.0",
|
||||
"symfony/phpunit-bridge": "^3.3",
|
||||
"symfony/stopwatch": "^2.8|^3.0|^4.0",
|
||||
"symfony/templating": "^3.4|^4.0",
|
||||
"symfony/twig-bundle": "^3.4|^4.0",
|
||||
"symfony/asset": "^3.4|^4.0",
|
||||
"symfony/console": "^3.4|^4.0",
|
||||
"symfony/config": "^3.4|^4.0",
|
||||
"symfony/validator": "^3.4|^4.0",
|
||||
"symfony/property-access": "^3.4|^4.0",
|
||||
"symfony/form": "^3.4|^4.0",
|
||||
"symfony/dom-crawler": "^3.4|^4.0",
|
||||
"symfony/browser-kit": "^3.4|^4.0",
|
||||
"symfony/cache": "^3.4|^4.0",
|
||||
"symfony/phpunit-bridge": "^3.4",
|
||||
"symfony/stopwatch": "^3.4|^4.0",
|
||||
"sensio/framework-extra-bundle": "^3.0",
|
||||
"symfony/stopwatch": "^2.8|^3.0|^4.0",
|
||||
"doctrine/annotations": "^1.2",
|
||||
|
||||
"phpdocumentor/reflection-docblock": "^3.1",
|
||||
@ -56,7 +55,7 @@
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0.x-dev"
|
||||
"dev-master": "3.1.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user