Skip to content

Commit 3b639b0

Browse files
committed
Merge 3.2
2 parents e895b69 + db50a46 commit 3b639b0

File tree

21 files changed

+153
-22
lines changed

21 files changed

+153
-22
lines changed

.github/workflows/guides.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ jobs:
4242
restore-keys: ${{ runner.os }}-composer-
4343
- name: Install project dependencies
4444
working-directory: docs
45-
run: composer install --no-interaction --no-progress --ansi && composer require webonyx/graphql-php
45+
run: |
46+
composer update --no-interaction --no-progress --ansi
47+
cp -r ../src ./vendor/api-platform/core/
4648
- name: Test guides
4749
working-directory: docs
4850
env:

docs/composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"zenstruck/foundry": "^1.31",
3535
"symfony/http-client": "^7.0",
3636
"symfony/browser-kit": "^7.0",
37-
"justinrainbow/json-schema": "^5.2"
37+
"justinrainbow/json-schema": "^5.2",
38+
"webonyx/graphql-php": "^15.11"
3839
},
3940
"config": {
4041
"allow-plugins": {
@@ -43,6 +44,5 @@
4344
},
4445
"require-dev": {
4546
"phpunit/phpunit": "^10"
46-
},
47-
"minimum-stability": "dev"
47+
}
4848
}

docs/config/packages/framework.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ api_platform:
77
json: ['application/json']
88
docs_formats:
99
jsonopenapi: ['application/vnd.openapi+json']
10-
event_listeners_backward_compatibility_layer: false
1110
keep_legacy_inflector: false
1211
defaults:
1312
extra_properties:
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Feature: Test entity class option on collections
2+
In order to retrieve a collections of resources mapped to a DTO automatically
3+
As a client software developer
4+
5+
@createSchema
6+
@!mongodb
7+
Scenario: Get collection
8+
Given there are issue6039 users
9+
And I add "Accept" header equal to "application/ld+json"
10+
When I send a "GET" request to "/issue6039_user_apis"
11+
Then the response status code should be 200
12+
And the JSON node "hydra:member[0].bar" should not exist

src/Doctrine/Odm/Filter/AbstractFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected function isPropertyEnabled(string $property, string $resourceClass): b
8686
protected function denormalizePropertyName(string|int $property): string
8787
{
8888
if (!$this->nameConverter instanceof NameConverterInterface) {
89-
return $property;
89+
return (string) $property;
9090
}
9191

9292
return implode('.', array_map($this->nameConverter->denormalize(...), explode('.', (string) $property)));

src/Doctrine/Orm/Filter/AbstractFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ protected function isPropertyEnabled(string $property, string $resourceClass): b
8080
protected function denormalizePropertyName(string|int $property): string
8181
{
8282
if (!$this->nameConverter instanceof NameConverterInterface) {
83-
return $property;
83+
return (string) $property;
8484
}
8585

8686
return implode('.', array_map($this->nameConverter->denormalize(...), explode('.', (string) $property)));

src/Hydra/Serializer/DocumentationNormalizer.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use ApiPlatform\Metadata\ApiProperty;
2121
use ApiPlatform\Metadata\ApiResource;
2222
use ApiPlatform\Metadata\CollectionOperationInterface;
23+
use ApiPlatform\Metadata\ErrorResource;
2324
use ApiPlatform\Metadata\HttpOperation;
2425
use ApiPlatform\Metadata\Operation;
2526
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
@@ -29,6 +30,7 @@
2930
use ApiPlatform\Metadata\ResourceClassResolverInterface;
3031
use ApiPlatform\Metadata\UrlGeneratorInterface;
3132
use ApiPlatform\Serializer\CacheableSupportsMethodInterface;
33+
use ApiPlatform\Symfony\Validator\Exception\ValidationException;
3234
use Symfony\Component\PropertyInfo\Type;
3335
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;
3436
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
@@ -60,6 +62,10 @@ public function normalize(mixed $object, ?string $format = null, array $context
6062
$resourceMetadataCollection = $this->resourceMetadataFactory->create($resourceClass);
6163

6264
$resourceMetadata = $resourceMetadataCollection[0];
65+
if ($resourceMetadata instanceof ErrorResource && ValidationException::class === $resourceMetadata->getClass()) {
66+
continue;
67+
}
68+
6369
$shortName = $resourceMetadata->getShortName();
6470
$prefixedShortName = $resourceMetadata->getTypes()[0] ?? "#$shortName";
6571
$this->populateEntrypointProperties($resourceMetadata, $shortName, $prefixedShortName, $entrypointProperties, $resourceMetadataCollection);

src/Metadata/Extractor/XmlResourceExtractor.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
namespace ApiPlatform\Metadata\Extractor;
1515

16+
use ApiPlatform\Elasticsearch\State\Options;
1617
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
1718
use ApiPlatform\Metadata\GetCollection;
1819
use ApiPlatform\Metadata\HeaderParameter;
1920
use ApiPlatform\Metadata\Post;
2021
use ApiPlatform\Metadata\QueryParameter;
21-
use ApiPlatform\Metadata\Tests\Fixtures\StateOptions;
2222
use ApiPlatform\OpenApi\Model\ExternalDocumentation;
2323
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
2424
use ApiPlatform\OpenApi\Model\Parameter as OpenApiParameter;
@@ -455,10 +455,12 @@ private function buildStateOptions(\SimpleXMLElement $resource): ?OptionsInterfa
455455
}
456456
$elasticsearchOptions = $stateOptions->elasticsearchOptions ?? null;
457457
if ($elasticsearchOptions) {
458-
return new StateOptions(
459-
isset($elasticsearchOptions['index']) ? (string) $elasticsearchOptions['index'] : null,
460-
isset($elasticsearchOptions['type']) ? (string) $elasticsearchOptions['type'] : null,
461-
);
458+
if (class_exists(Options::class)) {
459+
return new Options(
460+
isset($elasticsearchOptions['index']) ? (string) $elasticsearchOptions['index'] : null,
461+
isset($elasticsearchOptions['type']) ? (string) $elasticsearchOptions['type'] : null,
462+
);
463+
}
462464
}
463465

464466
return null;

src/Metadata/Extractor/YamlResourceExtractor.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313

1414
namespace ApiPlatform\Metadata\Extractor;
1515

16+
use ApiPlatform\Elasticsearch\State\Options;
1617
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
1718
use ApiPlatform\Metadata\GetCollection;
1819
use ApiPlatform\Metadata\HeaderParameter;
1920
use ApiPlatform\Metadata\Post;
2021
use ApiPlatform\Metadata\QueryParameter;
21-
use ApiPlatform\Metadata\Tests\Fixtures\StateOptions;
2222
use ApiPlatform\OpenApi\Model\ExternalDocumentation;
2323
use ApiPlatform\OpenApi\Model\Operation as OpenApiOperation;
2424
use ApiPlatform\OpenApi\Model\Parameter;
@@ -414,7 +414,9 @@ private function buildStateOptions(array $resource): ?OptionsInterface
414414
$configuration = reset($stateOptions);
415415
switch (key($stateOptions)) {
416416
case 'elasticsearchOptions':
417-
return new StateOptions($configuration['index'] ?? null, $configuration['type'] ?? null);
417+
if (class_exists(Options::class)) {
418+
return new Options($configuration['index'] ?? null, $configuration['type'] ?? null);
419+
}
418420
}
419421

420422
return null;

src/Metadata/Resource/Factory/OperationDefaultsTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private function getOperationWithDefaults(ApiResource $resource, Operation $oper
202202
throw new RuntimeException(sprintf('Operation should be an instance of "%s"', HttpOperation::class));
203203
}
204204

205-
if ($operation->getRouteName()) {
205+
if (!$operation->getName() && $operation->getRouteName()) {
206206
/** @var HttpOperation $operation */
207207
$operation = $operation->withName($operation->getRouteName());
208208
}

0 commit comments

Comments
 (0)