Skip to content

Commit

Permalink
Merge pull request #1368 from meyerbaptiste/merge_2.1
Browse files Browse the repository at this point in the history
Merge branch '2.1'
  • Loading branch information
meyerbaptiste committed Sep 13, 2017
2 parents 084be5b + fe04d6f commit 0607640
Show file tree
Hide file tree
Showing 26 changed files with 137 additions and 85 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -31,6 +31,7 @@
* Add support for API key authentication in Swagger UI
* Allow to specify a whitelist of serialization groups
* Allow to use the new immutable date and time types of Doctrine in filters
* Update swagger definition keys to more verbose ones (ie `Resource-md5($groups)` => `Resource-groupa_groupb`) - see https://github.com/api-platform/core/pull/1207

## 2.0.11

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -56,7 +56,7 @@
"symfony/finder": "^3.3 || ^4.0",
"symfony/form": "^3.3 || ^4.0",
"symfony/framework-bundle": "^3.3 || ^4.0",
"symfony/phpunit-bridge": "^2.7 || ^3.0 || ^4.0",
"symfony/phpunit-bridge": "^3.3 || ^4.0",
"symfony/routing": "^3.3 || ^4.0",
"symfony/security": "^3.0 || ^4.0",
"symfony/security-bundle": "^3.0 || ^4.0",
Expand Down
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Expand Up @@ -8,6 +8,7 @@
colors="true"
>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak_vendors" />
<ini name="error_reporting" value="-1" />
<ini name="memory_limit" value="-1" />
<server name="KERNEL_DIR" value="tests/Fixtures/app/" />
Expand All @@ -29,4 +30,8 @@
</exclude>
</whitelist>
</filter>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
</listeners>
</phpunit>
2 changes: 1 addition & 1 deletion src/Api/OperationTypeDeprecationHelper.php
Expand Up @@ -36,7 +36,7 @@ final class OperationTypeDeprecationHelper
public static function getOperationType($operationType): string
{
if (is_bool($operationType)) {
@trigger_error('Using a boolean for the Operation Type is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3', E_USER_DEPRECATED);
@trigger_error('Using a boolean for the Operation Type is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3', E_USER_DEPRECATED);

$operationType = $operationType === true ? OperationType::COLLECTION : OperationType::ITEM;
}
Expand Down
Expand Up @@ -32,6 +32,8 @@
*
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Teoh Han Hui <teohhanhui@gmail.com>
*
* @deprecated since version 2.2, to be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
final class ApiPlatformProvider implements AnnotationsProviderInterface
{
Expand All @@ -47,14 +49,14 @@ final class ApiPlatformProvider implements AnnotationsProviderInterface
*/
public function __construct(ResourceNameCollectionFactoryInterface $resourceNameCollectionFactory, NormalizerInterface $documentationNormalizer, ResourceMetadataFactoryInterface $resourceMetadataFactory, $filterLocator, OperationMethodResolverInterface $operationMethodResolver)
{
@trigger_error('The '.__CLASS__.' class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.', E_USER_DEPRECATED);

$this->setFilterLocator($filterLocator);

$this->resourceNameCollectionFactory = $resourceNameCollectionFactory;
$this->documentationNormalizer = $documentationNormalizer;
$this->resourceMetadataFactory = $resourceMetadataFactory;
$this->operationMethodResolver = $operationMethodResolver;

@trigger_error('The '.__NAMESPACE__.'\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.', E_USER_DEPRECATED);
}

/**
Expand Down
6 changes: 4 additions & 2 deletions src/Bridge/NelmioApiDoc/Parser/ApiPlatformParser.php
Expand Up @@ -29,6 +29,8 @@
*
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Teoh Han Hui <teohhanhui@gmail.com>
*
* @deprecated since version 2.2, to be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
final class ApiPlatformParser implements ParserInterface
{
Expand All @@ -49,12 +51,12 @@ final class ApiPlatformParser implements ParserInterface

public function __construct(ResourceMetadataFactoryInterface $resourceMetadataFactory, PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, PropertyMetadataFactoryInterface $propertyMetadataFactory, NameConverterInterface $nameConverter = null)
{
@trigger_error('The '.__CLASS__.' class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.', E_USER_DEPRECATED);

$this->resourceMetadataFactory = $resourceMetadataFactory;
$this->propertyNameCollectionFactory = $propertyNameCollectionFactory;
$this->propertyMetadataFactory = $propertyMetadataFactory;
$this->nameConverter = $nameConverter;

@trigger_error('The '.__NAMESPACE__.'\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 2 has native support for API Platform.', E_USER_DEPRECATED);
}

/**
Expand Down
12 changes: 11 additions & 1 deletion src/Bridge/Symfony/Bundle/DependencyInjection/Configuration.php
Expand Up @@ -66,7 +66,17 @@ public function getConfigTreeBuilder()
->end()
->end()
->booleanNode('enable_fos_user')->defaultValue(class_exists(FOSUserBundle::class))->info('Enable the FOSUserBundle integration.')->end()
->booleanNode('enable_nelmio_api_doc')->defaultValue(false)->info('Enable the Nelmio Api doc integration.')->end()
->booleanNode('enable_nelmio_api_doc')
->beforeNormalization()->always(function ($v) {
if ($v) {
@trigger_error('Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.', E_USER_DEPRECATED);
}

return $v;
})->end()
->defaultValue(false)
->info('[Deprecated] Enable the NelmioApiDocBundle integration.')
->end()
->booleanNode('enable_swagger')->defaultValue(true)->info('Enable the Swagger documentation and export.')->end()
->booleanNode('enable_swagger_ui')->defaultValue(class_exists(TwigBundle::class))->info('Enable Swagger ui.')->end()

Expand Down
4 changes: 2 additions & 2 deletions src/Bridge/Symfony/Bundle/Resources/config/api.xml
Expand Up @@ -102,11 +102,11 @@
</service>

<service id="api_platform.operation_path_resolver.underscore" class="ApiPlatform\Core\PathResolver\UnderscoreOperationPathResolver" public="false">
<deprecated>The "%service_id%" service is deprecated since ApiPlatform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.underscore" instead.</deprecated>
<deprecated>The "%service_id%" service is deprecated since API Platform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.underscore" instead.</deprecated>
</service>

<service id="api_platform.operation_path_resolver.dash" class="ApiPlatform\Core\PathResolver\DashOperationPathResolver" public="false">
<deprecated>The "%service_id%" service is deprecated since ApiPlatform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.dash" instead.</deprecated>
<deprecated>The "%service_id%" service is deprecated since API Platform 2.1 and will be removed in 3.0. Use "api_platform.path_segment_name_generator.dash" instead.</deprecated>
</service>

<!-- Path name generator -->
Expand Down
4 changes: 4 additions & 0 deletions src/Bridge/Symfony/Bundle/Resources/config/nelmio_api_doc.xml
Expand Up @@ -6,6 +6,8 @@

<services>
<service id="api_platform.nelmio_api_doc.annotations_provider" class="ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider">
<deprecated>The "%service_id%" service is deprecated since API Platform 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.</deprecated>

<argument type="service" id="api_platform.metadata.resource.name_collection_factory" />
<argument type="service" id="api_platform.hydra.normalizer.documentation" />
<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
Expand All @@ -16,6 +18,8 @@
</service>

<service id="api_platform.nelmio_api_doc.parser" class="ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser">
<deprecated>The "%service_id%" service is deprecated since API Platform 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.</deprecated>

<argument type="service" id="api_platform.metadata.resource.metadata_factory" />
<argument type="service" id="api_platform.metadata.property.name_collection_factory" />
<argument type="service" id="api_platform.metadata.property.metadata_factory" />
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/Extractor/XmlExtractor.php
Expand Up @@ -65,7 +65,7 @@ private function getOperations(\SimpleXMLElement $resource, string $operationTyp
{
if ($legacyOperations = $this->getAttributes($resource, $operationType)) {
@trigger_error(
sprintf('Configuring "%1$s" tags without using a parent "%1$ss" tag is deprecrated since API Platform 2.1 and will not be possible anymore in API Platform 3', $operationType),
sprintf('Configuring "%1$s" tags without using a parent "%1$ss" tag is deprecated since API Platform 2.1 and will not be possible anymore in API Platform 3', $operationType),
E_USER_DEPRECATED
);

Expand Down
9 changes: 7 additions & 2 deletions src/PathResolver/DashOperationPathResolver.php
Expand Up @@ -19,16 +19,21 @@
* Generates a path with words separated by underscores.
*
* @author Paul Le Corre <paul@lecorre.me>
*
* @deprecated since version 2.1, to be removed in 3.0. Use {@see \ApiPlatform\Core\Operation\DashPathSegmentNameGenerator} instead.
*/
final class DashOperationPathResolver implements OperationPathResolverInterface
{
public function __construct()
{
@trigger_error(sprintf('The use of %s is deprecated since 2.1. Please use %s instead.', __CLASS__, DashPathSegmentNameGenerator::class), E_USER_DEPRECATED);
}

/**
* {@inheritdoc}
*/
public function resolveOperationPath(string $resourceShortName, array $operation, $operationType/*, string $operationName = null*/): string
{
@trigger_error(sprintf('The use of %s is deprecated since 2.1. Please use PathSegmentNameGenerator instead.', __CLASS__), E_USER_DEPRECATED);

if (func_num_args() >= 4) {
$operationName = func_get_arg(3);
} else {
Expand Down
9 changes: 7 additions & 2 deletions src/PathResolver/UnderscoreOperationPathResolver.php
Expand Up @@ -19,16 +19,21 @@
* Generates a path with words separated by underscores.
*
* @author Paul Le Corre <paul@lecorre.me>
*
* @deprecated since version 2.1, to be removed in 3.0. Use {@see \ApiPlatform\Core\Operation\UnderscorePathSegmentNameGenerator} instead.
*/
final class UnderscoreOperationPathResolver implements OperationPathResolverInterface
{
public function __construct()
{
@trigger_error(sprintf('The use of %s is deprecated since 2.1. Please use %s instead.', __CLASS__, UnderscorePathSegmentNameGenerator::class), E_USER_DEPRECATED);
}

/**
* {@inheritdoc}
*/
public function resolveOperationPath(string $resourceShortName, array $operation, $operationType/*, string $operationName = null*/): string
{
@trigger_error(sprintf('The use of %s is deprecated since 2.1. Please use PathSegmentNameGenerator instead.', __CLASS__), E_USER_DEPRECATED);

if (func_num_args() >= 4) {
$operationName = func_get_arg(3);
} else {
Expand Down
2 changes: 2 additions & 0 deletions src/Serializer/AbstractItemNormalizer.php
Expand Up @@ -357,6 +357,8 @@ protected function getFactoryOptions(array $context): array
* @param array $context
*
* @return array
*
* @deprecated since version 2.1, to be removed in 3.0.
*/
protected function createRelationSerializationContext(string $resourceClass, array $context): array
{
Expand Down
Expand Up @@ -34,10 +34,12 @@
* @author Teoh Han Hui <teohhanhui@gmail.com>
*
* @group legacy
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
class ApiPlatformProviderTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testConstruct()
{
$resourceNameCollectionFactoryProphecy = $this->prophesize(ResourceNameCollectionFactoryInterface::class);
Expand All @@ -60,6 +62,9 @@ public function testConstruct()
$this->assertInstanceOf(AnnotationsProviderInterface::class, $apiPlatformProvider);
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testGetAnnotations()
{
$dummySearchFilterProphecy = $this->prophesize(FilterInterface::class);
Expand All @@ -80,7 +85,7 @@ public function testGetAnnotations()
}

/**
* @group legacy
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
* @expectedDeprecation The ApiPlatform\Core\Api\FilterCollection class is deprecated since version 2.1 and will be removed in 3.0. Provide an implementation of Psr\Container\ContainerInterface instead.
*/
public function testGetAnnotationsWithDeprecatedFilterCollection()
Expand All @@ -99,7 +104,8 @@ public function testGetAnnotationsWithDeprecatedFilterCollection()
}

/**
* @group legacy
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Extractor\AnnotationsProvider\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The "$filterLocator" argument is expected to be an implementation of the "Psr\Container\ContainerInterface" interface.
*/
Expand Down
34 changes: 33 additions & 1 deletion tests/Bridge/NelmioApiDoc/Parser/ApiPlatformParserTest.php
Expand Up @@ -34,10 +34,12 @@
* @author Teoh Han Hui <teohhanhui@gmail.com>
*
* @group legacy
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformProvider class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
class ApiPlatformParserTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testConstruct()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand All @@ -54,6 +56,9 @@ public function testConstruct()
$this->assertInstanceOf(ParserInterface::class, $apiPlatformParser);
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testSupports()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand All @@ -73,6 +78,9 @@ public function testSupports()
]));
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testNoOnDataFirstArray()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand All @@ -92,6 +100,9 @@ public function testNoOnDataFirstArray()
]));
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testSupportsAttributeNormalization()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand Down Expand Up @@ -149,6 +160,9 @@ public function testSupportsAttributeNormalization()
], $actual);
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testSupportsUnknownResource()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand All @@ -168,6 +182,9 @@ public function testSupportsUnknownResource()
]));
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testSupportsUnsupportedClassFormat()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand All @@ -187,6 +204,9 @@ public function testSupportsUnsupportedClassFormat()
]));
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testParse()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand Down Expand Up @@ -258,6 +278,9 @@ public function testParse()
], $actual);
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testParseDateTime()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand Down Expand Up @@ -297,6 +320,9 @@ public function testParseDateTime()
], $actual);
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testParseRelation()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand Down Expand Up @@ -385,6 +411,9 @@ public function testParseRelation()
], $actual);
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testParseWithNameConverter()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand Down Expand Up @@ -427,6 +456,9 @@ public function testParseWithNameConverter()
], $actual);
}

/**
* @expectedDeprecation The ApiPlatform\Core\Bridge\NelmioApiDoc\Parser\ApiPlatformParser class is deprecated since version 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testParseRecursive()
{
$resourceMetadataFactoryProphecy = $this->prophesize(ResourceMetadataFactoryInterface::class);
Expand Down
Expand Up @@ -206,6 +206,10 @@ public function testFosUserPriority()
);
}

/**
* @group legacy
* @expectedDeprecation Enabling the NelmioApiDocBundle integration has been deprecated in 2.2 and will be removed in 3.0. NelmioApiDocBundle 3 has native support for API Platform.
*/
public function testEnableNelmioApiDoc()
{
$containerBuilderProphecy = $this->getContainerBuilderProphecy();
Expand Down

0 comments on commit 0607640

Please sign in to comment.