Skip to content

Commit e2a7194

Browse files
committed
Merge branch '2.4'
2 parents bf867e0 + e3f228a commit e2a7194

File tree

4 files changed

+97
-15
lines changed

4 files changed

+97
-15
lines changed

CHANGELOG.md

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,53 @@
44

55
* GraphQL: Add support for custom types
66

7+
## 2.4.0 beta 2
8+
9+
* Fix version constraints for Doctrine MongoDB ODM
10+
* Respect `_api_respond` request attribute in the SerializeListener
11+
* Change the normalizer's priorities (`< 0`). If you have custom normalizer we recommend to use positive priorities.
12+
13+
| Service name | Priority | Class |
14+
|------------------------------------------------------------|------|---------------------------------------------------------|
15+
| api_platform.hydra.normalizer.constraint_violation_list | -780 | ApiPlatform\Core\Hydra\Serializer\ConstraintViolationListNormalizer
16+
| api_platform.jsonapi.normalizer.constraint_violation_list | -780 | ApiPlatform\Core\JsonApi\Serializer\ConstraintViolationListNormalizer
17+
| api_platform.problem.normalizer.constraint_violation_list | -780 | ApiPlatform\Core\Problem\Serializer\ConstraintViolationListNormalizer
18+
| api_platform.swagger.normalizer.api_gateway | -780 | ApiPlatform\Core\Swagger\Serializer\ApiGatewayNormalizer
19+
| api_platform.hal.normalizer.collection | -790 | ApiPlatform\Core\Hal\Serializer\CollectionNormalizer
20+
| api_platform.hydra.normalizer.collection_filters | -790 | ApiPlatform\Core\Hydra\Serializer\CollectionFiltersNormalizer
21+
| api_platform.jsonapi.normalizer.collection | -790 | ApiPlatform\Core\JsonApi\Serializer\CollectionNormalizer
22+
| api_platform.jsonapi.normalizer.error | -790 | ApiPlatform\Core\JsonApi\Serializer\ErrorNormalizer
23+
| api_platform.hal.normalizer.entrypoint | -800 | ApiPlatform\Core\Hal\Serializer\EntrypointNormalizer
24+
| api_platform.hydra.normalizer.documentation | -800 | ApiPlatform\Core\Hydra\Serializer\DocumentationNormalizer
25+
| api_platform.hydra.normalizer.entrypoint | -800 | ApiPlatform\Core\Hydra\Serializer\EntrypointNormalizer
26+
| api_platform.hydra.normalizer.error | -800 | ApiPlatform\Core\Hydra\Serializer\ErrorNormalizer
27+
| api_platform.jsonapi.normalizer.entrypoint | -800 | ApiPlatform\Core\JsonApi\Serializer\EntrypointNormalizer
28+
| api_platform.problem.normalizer.error | -810 | ApiPlatform\Core\Problem\Serializer\ErrorNormalizer
29+
| serializer.normalizer.json_serializable | -900 | Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer
30+
| serializer.normalizer.datetime | -910 | Symfony\Component\Serializer\Normalizer\DateTimeNormalizer
31+
| serializer.normalizer.constraint_violation_list | -915 | Symfony\Component\Serializer\Normalizer\ConstraintViolationListNormalizer
32+
| serializer.normalizer.dateinterval | -915 | Symfony\Component\Serializer\Normalizer\DateIntervalNormalizer
33+
| serializer.normalizer.data_uri | -920 | Symfony\Component\Serializer\Normalizer\DataUriNormalizer
34+
| api_platform.graphql.normalizer.item | -922 | ApiPlatform\Core\GraphQl\Serializer\ItemNormalizer
35+
| api_platform.hal.normalizer.item | -922 | ApiPlatform\Core\Hal\Serializer\ItemNormalizer
36+
| api_platform.jsonapi.normalizer.item | -922 | ApiPlatform\Core\JsonApi\Serializer\ItemNormalizer
37+
| api_platform.jsonld.normalizer.item | -922 | ApiPlatform\Core\JsonLd\Serializer\ItemNormalizer
38+
| api_platform.serializer.normalizer.item | -923 | ApiPlatform\Core\Serializer\ItemNormalizer
39+
| serializer.normalizer.object | -1000 | Symfony\Component\Serializer\Normalizer\ObjectNormalizer
40+
41+
* Allow custom stylesheets to be appended or replaced in the swagger UI
42+
* Load messenger only if available
43+
* Fix missing metadata cache pool for Elasticsearch
44+
* Make use of the new AdvancedNameConverterInterface interface for name converters
45+
* Refactor input/output attributes, where these attributes now take:
46+
- an array specifying a class and some specific attributes (`name` and `iri` if needed)
47+
- a string representing the class
48+
- a `falsy` boolean to disable the input/output
49+
* Introduce the DataTransformer concept to transform an input/output from/to a resource
50+
* Api Platform normalizer is not limited to Resources anymore (you can use DTO as relations and more...)
51+
* MongoDB: allow a `0` limit in the pagination
52+
* Fix support of a discriminator mapping in an entity
53+
754
## 2.4.0 beta 1
855

956
* MongoDB: full support
@@ -207,7 +254,7 @@
207254

208255
## 2.2.2
209256

210-
* Autoregister classes implementing `SubresourceDataProviderInterface`
257+
* Autoregister classes implementing `SubresourceDataProviderInterface`
211258
* Fix the `DateTimeImmutable` support in the date filter
212259
* Fix a BC break in `DocumentationAction` impacting NelmioApiDoc
213260
* Fix the context passed to data providers (improve the eager loading)
@@ -237,9 +284,9 @@
237284
* Remove the `api_platform.doctrine.listener.view.write` event listener service.
238285
* Add a data persistence layer with a new `ApiPlatform\Core\DataPersister\DataPersisterInterface` interface.
239286
* Add the a new configuration to disable the API entrypoint and the documentation
240-
* Allow to set maximum items per page at operation/resource level
287+
* Allow to set maximum items per page at operation/resource level
241288
* Add the ability to customize the message when configuring an access control rule trough the `access_control_message` attribute
242-
* Allow empty operations in XML configs
289+
* Allow empty operations in XML configs
243290

244291
## 2.1.6
245292

@@ -266,14 +313,14 @@
266313
## 2.1.4
267314

268315
* Symfony 3.4 and 4.0 compatibility
269-
* Autowiring strict mode compatibility
316+
* Autowiring strict mode compatibility
270317
* Fix a bug preventing to create resource classes in the global namespace
271318
* Fix Doctrine type conversion in filter's WHERE clauses
272319
* Fix filters when using eager loading and non-association composite identifier
273-
* Fix Doctrine type resolution for identifiers (for custom DBALType)
320+
* Fix Doctrine type resolution for identifiers (for custom DBALType)
274321
* Add missing Symfony Routing options to operations configuration
275322
* Add SubresourceOperations to metadata
276-
* Fix disabling of cache pools with the dev environment
323+
* Fix disabling of cache pools with the dev environment
277324

278325
## 2.1.3
279326

src/Identifier/ContextAwareIdentifierConverterInterface.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,10 @@
1414
namespace ApiPlatform\Core\Identifier;
1515

1616
/**
17-
* Identifier converter.
17+
* Gives access to the context in the IdentifierConverter.
1818
*
1919
* @author Antoine Bluchet <[email protected]>
2020
*/
21-
22-
namespace ApiPlatform\Core\Identifier;
23-
24-
/**
25-
* Gives access to the context.
26-
*
27-
* @author Kévin Dunglas <[email protected]>
28-
*/
2921
interface ContextAwareIdentifierConverterInterface extends IdentifierConverterInterface
3022
{
3123
/**

src/Serializer/AbstractItemNormalizer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,10 @@ private function createAttributeValue($attribute, $value, $format = null, array
336336
return $this->denormalizeRelation($attribute, $propertyMetadata, $className, $value, $format, $this->createChildContext($context, $attribute));
337337
}
338338

339+
if ($context[static::DISABLE_TYPE_ENFORCEMENT] ?? false) {
340+
return $value;
341+
}
342+
339343
$this->validateType($attribute, $type, $value, $format);
340344

341345
return $value;

tests/Serializer/AbstractItemNormalizerTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,45 @@ public function testBadType()
626626
$normalizer->denormalize(['foo' => 42], Dummy::class);
627627
}
628628

629+
public function testTypeChecksCanBeDisabled()
630+
{
631+
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);
632+
$propertyNameCollectionFactoryProphecy->create(Dummy::class, [])->willReturn(
633+
new PropertyNameCollection(['foo'])
634+
)->shouldBeCalled();
635+
636+
$propertyMetadataFactoryProphecy = $this->prophesize(PropertyMetadataFactoryInterface::class);
637+
$propertyMetadataFactoryProphecy->create(Dummy::class, 'foo', [])->willReturn(
638+
new PropertyMetadata(new Type(Type::BUILTIN_TYPE_FLOAT), '', false, true, false, false)
639+
)->shouldBeCalled();
640+
641+
$iriConverterProphecy = $this->prophesize(IriConverterInterface::class);
642+
$propertyAccessorProphecy = $this->prophesize(PropertyAccessorInterface::class);
643+
$resourceClassResolverProphecy = $this->prophesize(ResourceClassResolverInterface::class);
644+
645+
$serializerProphecy = $this->prophesize(SerializerInterface::class);
646+
$serializerProphecy->willImplement(DenormalizerInterface::class);
647+
648+
$normalizer = $this->getMockForAbstractClass(AbstractItemNormalizer::class, [
649+
$propertyNameCollectionFactoryProphecy->reveal(),
650+
$propertyMetadataFactoryProphecy->reveal(),
651+
$iriConverterProphecy->reveal(),
652+
$resourceClassResolverProphecy->reveal(),
653+
$propertyAccessorProphecy->reveal(),
654+
null,
655+
null,
656+
null,
657+
false,
658+
[],
659+
[],
660+
null,
661+
true,
662+
]);
663+
$normalizer->setSerializer($serializerProphecy->reveal());
664+
665+
$normalizer->denormalize(['foo' => 42], Dummy::class, null, ['disable_type_enforcement' => true]);
666+
}
667+
629668
public function testJsonAllowIntAsFloat()
630669
{
631670
$propertyNameCollectionFactoryProphecy = $this->prophesize(PropertyNameCollectionFactoryInterface::class);

0 commit comments

Comments
 (0)