Skip to content

Commit 1c98fd4

Browse files
authored
Merge pull request #6561 from soyuka/merge-34
Merge 3.4
2 parents cd2dbd0 + 6d3d716 commit 1c98fd4

16 files changed

+91
-34
lines changed

src/Laravel/ApiPlatformProvider.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@
9696
use ApiPlatform\Laravel\Metadata\CachePropertyMetadataFactory;
9797
use ApiPlatform\Laravel\Metadata\CachePropertyNameCollectionMetadataFactory;
9898
use ApiPlatform\Laravel\Metadata\CacheResourceCollectionMetadataFactory;
99-
use ApiPlatform\Laravel\Metadata\ConcernsPropertyNameCollectionMetadataFactory;
100-
use ApiPlatform\Laravel\Metadata\ConcernsResourceMetadataCollectionFactory;
101-
use ApiPlatform\Laravel\Metadata\ConcernsResourceNameCollectionFactory;
10299
use ApiPlatform\Laravel\Routing\IriConverter;
103100
use ApiPlatform\Laravel\Routing\Router as UrlGeneratorRouter;
104101
use ApiPlatform\Laravel\Routing\SkolemIriConverter;
@@ -108,7 +105,6 @@
108105
use ApiPlatform\Laravel\State\SwaggerUiProvider;
109106
use ApiPlatform\Laravel\State\ValidateProvider;
110107
use ApiPlatform\Metadata\Exception\NotExposedHttpException;
111-
use ApiPlatform\Metadata\Factory\Property\ClassLevelAttributePropertyNameCollectionFactory;
112108
use ApiPlatform\Metadata\FilterInterface;
113109
use ApiPlatform\Metadata\IdentifiersExtractor;
114110
use ApiPlatform\Metadata\IdentifiersExtractorInterface;
@@ -119,6 +115,8 @@
119115
use ApiPlatform\Metadata\Operation\PathSegmentNameGeneratorInterface;
120116
use ApiPlatform\Metadata\Operation\UnderscorePathSegmentNameGenerator;
121117
use ApiPlatform\Metadata\Property\Factory\AttributePropertyMetadataFactory;
118+
use ApiPlatform\Metadata\Property\Factory\ClassLevelAttributePropertyNameCollectionFactory;
119+
use ApiPlatform\Metadata\Property\Factory\ConcernsPropertyNameCollectionMetadataFactory;
122120
use ApiPlatform\Metadata\Property\Factory\PropertyInfoPropertyMetadataFactory;
123121
use ApiPlatform\Metadata\Property\Factory\PropertyInfoPropertyNameCollectionFactory;
124122
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
@@ -127,6 +125,8 @@
127125
use ApiPlatform\Metadata\Resource\Factory\AlternateUriResourceMetadataCollectionFactory;
128126
use ApiPlatform\Metadata\Resource\Factory\AttributesResourceMetadataCollectionFactory;
129127
use ApiPlatform\Metadata\Resource\Factory\AttributesResourceNameCollectionFactory;
128+
use ApiPlatform\Metadata\Resource\Factory\ConcernsResourceMetadataCollectionFactory;
129+
use ApiPlatform\Metadata\Resource\Factory\ConcernsResourceNameCollectionFactory;
130130
use ApiPlatform\Metadata\Resource\Factory\FiltersResourceMetadataCollectionFactory;
131131
use ApiPlatform\Metadata\Resource\Factory\FormatsResourceMetadataCollectionFactory;
132132
use ApiPlatform\Metadata\Resource\Factory\InputOutputResourceMetadataCollectionFactory;

src/Laravel/workbench/app/Models/Author.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Workbench\App\Models;
1515

16-
use ApiPlatform\Laravel\IsApiResource;
16+
use ApiPlatform\Metadata\IsApiResource;
1717
use Illuminate\Database\Eloquent\Factories\HasFactory;
1818
use Illuminate\Database\Eloquent\Model;
1919

src/Laravel/IsApiResource.php renamed to src/Metadata/IsApiResource.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Laravel;
15-
16-
use ApiPlatform\Metadata\ApiResource;
14+
namespace ApiPlatform\Metadata;
1715

1816
/**
1917
* @author Kévin Dunglas <[email protected]>

src/Metadata/Factory/Property/ClassLevelAttributePropertyNameCollectionFactory.php renamed to src/Metadata/Property/Factory/ClassLevelAttributePropertyNameCollectionFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Metadata\Factory\Property;
14+
namespace ApiPlatform\Metadata\Property\Factory;
1515

1616
use ApiPlatform\Metadata\ApiProperty;
17-
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
1817
use ApiPlatform\Metadata\Property\PropertyNameCollection;
1918

2019
/**

src/Laravel/Metadata/ConcernsPropertyNameCollectionMetadataFactory.php renamed to src/Metadata/Property/Factory/ConcernsPropertyNameCollectionMetadataFactory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Laravel\Metadata;
14+
namespace ApiPlatform\Metadata\Property\Factory;
1515

16-
use ApiPlatform\Laravel\IsApiResource;
1716
use ApiPlatform\Metadata\ApiProperty;
18-
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
17+
use ApiPlatform\Metadata\IsApiResource;
1918
use ApiPlatform\Metadata\Property\PropertyNameCollection;
2019

2120
/**

src/Laravel/Metadata/ConcernsResourceMetadataCollectionFactory.php renamed to src/Metadata/Resource/Factory/ConcernsResourceMetadataCollectionFactory.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Laravel\Metadata;
14+
namespace ApiPlatform\Metadata\Resource\Factory;
1515

16-
use ApiPlatform\Laravel\IsApiResource;
17-
use ApiPlatform\Metadata\Resource\Factory\MetadataCollectionFactoryTrait;
18-
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
16+
use ApiPlatform\Metadata\IsApiResource;
1917
use ApiPlatform\Metadata\Resource\ResourceMetadataCollection;
2018

2119
/**

src/Laravel/Metadata/ConcernsResourceNameCollectionFactory.php renamed to src/Metadata/Resource/Factory/ConcernsResourceNameCollectionFactory.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111

1212
declare(strict_types=1);
1313

14-
namespace ApiPlatform\Laravel\Metadata;
14+
namespace ApiPlatform\Metadata\Resource\Factory;
1515

16-
use ApiPlatform\Laravel\IsApiResource;
17-
use ApiPlatform\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
16+
use ApiPlatform\Metadata\IsApiResource;
1817
use ApiPlatform\Metadata\Resource\ResourceNameCollection;
1918
use ApiPlatform\Metadata\Util\ReflectionClassRecursiveIterator;
2019

src/OpenApi/Factory/OpenApiFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ private function collectPaths(ApiResource $resource, ResourceMetadataCollection
304304
}
305305
}
306306

307-
if (!$operation instanceof CollectionOperationInterface && 'POST' !== $operation->getMethod()) {
307+
if (true === $overrideResponses && !$operation instanceof CollectionOperationInterface && 'POST' !== $operation->getMethod()) {
308308
if (!isset($existingResponses[404])) {
309309
$openapiOperation = $openapiOperation->withResponse(404, new Response('Resource not found'));
310310
}

src/OpenApi/Model/PathItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getServers(): ?array
8383
return $this->servers;
8484
}
8585

86-
public function getParameters(): array
86+
public function getParameters(): ?array
8787
{
8888
return $this->parameters;
8989
}

src/Serializer/AbstractItemNormalizer.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -522,9 +522,14 @@ protected function denormalizeCollection(string $attribute, ApiProperty $propert
522522
$childContext = $this->createChildContext($this->createOperationContext($context, $className), $attribute, $format);
523523
$collectionKeyTypes = $type->getCollectionKeyTypes();
524524
foreach ($value as $index => $obj) {
525+
$currentChildContext = $childContext;
526+
if (isset($childContext['deserialization_path'])) {
527+
$currentChildContext['deserialization_path'] = "{$childContext['deserialization_path']}[{$index}]";
528+
}
529+
525530
// no typehint provided on collection key
526531
if (!$collectionKeyTypes) {
527-
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $childContext);
532+
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $currentChildContext);
528533
continue;
529534
}
530535

@@ -535,7 +540,7 @@ protected function denormalizeCollection(string $attribute, ApiProperty $propert
535540
continue;
536541
}
537542

538-
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $childContext);
543+
$values[$index] = $this->denormalizeRelation($attribute, $propertyMetadata, $className, $obj, $format, $currentChildContext);
539544
continue 2;
540545
}
541546
throw NotNormalizableValueException::createForUnexpectedDataType(\sprintf('The type of the key "%s" must be "%s", "%s" given.', $index, $collectionKeyTypes[0]->getBuiltinType(), \gettype($index)), $index, [$collectionKeyTypes[0]->getBuiltinType()], ($context['deserialization_path'] ?? false) ? \sprintf('key(%s)', $context['deserialization_path']) : null, true);

0 commit comments

Comments
 (0)