Skip to content

Commit 6606dd4

Browse files
committed
Merge 3.2
2 parents e10cc5e + ad2cbe0 commit 6606dd4

File tree

96 files changed

+1285
-366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1285
-366
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
'tests/Fixtures/app/var',
1919
'docs/guides',
2020
'docs/var',
21+
'**vendor**'
2122
])
2223
->notPath('src/Symfony/Bundle/DependencyInjection/Configuration.php')
2324
->notPath('src/Annotation/ApiFilter.php') // temporary

CHANGELOG.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,33 @@
11
# Changelog
22

3+
## v3.2.2
4+
5+
### Bug fixes
6+
7+
* [3d0dfc148](https://github.com/api-platform/core/commit/3d0dfc148ec864364d1c36dfaa2690e1fc58dfc5) fix(symfony): swagger ui should use base url (#5918)
8+
* [4f51b5198](https://github.com/api-platform/core/commit/4f51b519853cf972070db79a8b82c824afa000fc) fix(symfony): use http exception headers (#5932)
9+
* [547c4e605](https://github.com/api-platform/core/commit/547c4e605c60c54642abc06c37462f5e47fbe25d) fix(graphql): item resolver inheritance error (#5910)
10+
* [6b5df95ca](https://github.com/api-platform/core/commit/6b5df95caf2e3c6f807f2083ea3526fcd2ae473a) fix(doctrine): odm order filter should use a left join on nullable fields (#5911)
11+
* [ae090c7c4](https://github.com/api-platform/core/commit/ae090c7c4ec9619655ae95534b87a07aa7b2b061) fix(graphql): use normalization context to get item from IRI (#5915)
12+
* [b2d9ce40c](https://github.com/api-platform/core/commit/b2d9ce40cf27ee9743aafff4f163e195ae47b880) fix(serializer): pass $context to IriConverter (#5908)
13+
* [c2824c1d7](https://github.com/api-platform/core/commit/c2824c1d72f04a0d05b902b08a475a95db18e69f) fix(jsonschema): restore type factory usage (#5897)
14+
* [cd6f5834b](https://github.com/api-platform/core/commit/cd6f5834b7458798054fb4c7b3ea94f193246405) fix(serializer): use error normalizers (#5931)
15+
* [d9f77402d](https://github.com/api-platform/core/commit/d9f77402d55c40a867edf8fa15cee67c2801574f) fix(graphql): service missing in debug mode (#5930)
16+
17+
Note:
18+
19+
`extra_properties.skip_deprecated_exception_normalizers` is set to `false` so that decorating Error normalizers works. Set it to `true` to avoid deprecations and decorate the corresponding `ItemNormalizer` instead.
20+
21+
## v3.2.1
22+
23+
### Bug fixes
24+
25+
* [05363d98f](https://github.com/api-platform/core/commit/05363d98f54babff49119a1fb55a17bb1550f21a) fix(symfony): force json format with GraphQL
26+
* [0c50d4ceb](https://github.com/api-platform/core/commit/0c50d4ceba9d83a2212771f21e2d1de4442c1456) fix(state): add link header processor without links (#5888)
27+
* [51b818304](https://github.com/api-platform/core/commit/51b818304874ec60ebab914455adc8f50402ca9d) fix: error traces without arguments (#5891)
28+
* [b7c094aca](https://github.com/api-platform/core/commit/b7c094acae3ac3271f42443ea2f62f22d019bea6) fix(metadata): interface breaking in 3.2 (#5883)
29+
* [dbd4f64de](https://github.com/api-platform/core/commit/dbd4f64debab876ab556ec87c8c973f0c38ada10) fix(graphql): docs should answer text/html
30+
331
## v3.2.0
432

533
### Bug fixes
@@ -147,6 +175,19 @@ Notes:
147175
* [92a81f024](https://github.com/api-platform/core/commit/92a81f024541054b9322e7457b75c721261e14e0) feat(graphql): allow to disable the introspection query (#5711)
148176
* [d793ffb92](https://github.com/api-platform/core/commit/d793ffb9228a21655ee35f0b90a959f93281a4cf) feat: union/intersect types (#5470)
149177

178+
## v3.1.22
179+
180+
### Bug fixes
181+
182+
* [157faafd5](https://github.com/api-platform/core/commit/157faafd54db75214b39fc8c7c6a97a171513c67) fix(state): wrong variable name
183+
* [b2d9ce40c](https://github.com/api-platform/core/commit/b2d9ce40cf27ee9743aafff4f163e195ae47b880) fix(serializer): pass $context to IriConverter (#5908)
184+
185+
## v3.1.21
186+
187+
### Bug fixes
188+
189+
* [364732d83](https://github.com/api-platform/core/commit/364732d838f2fba05887fd24c75c4fb302c7af04) fix(serializer): missing parenthesis fixes #5773
190+
150191
## v3.1.20
151192

152193
### Bug fixes
@@ -158,7 +199,7 @@ Notes:
158199
### Bug fixes
159200

160201
* [6a62a53f8](https://github.com/api-platform/core/commit/6a62a53f854ec93947d1c4a5a32007df09e55d06) fix(hydra): add xxx[] hydra:search iexact
161-
* [7f0e00cd2](https://github.com/api-platform/core/commit/7f0e00cd2d838037f716e0b8588a6529ef9f158c) fix(mercure): custom topics on newly created entities causes error #5074
202+
* [7f0e00cd2](https://github.com/api-platform/core/commit/7f0e00cd2d838037f716e0b8588a6529ef9f158c) fix(mercure): custom topics on newly created entities causes error #5074
162203
* [1fccb8413](https://github.com/api-platform/core/commit/1fccb8413a902a1011f049d0f8ddcd8d5456d335) fix(doctrine): add SearchFilter case-insensitive strategies constants
163204

164205
## v3.1.18
@@ -543,7 +584,7 @@ Breaking changes:
543584
* Metadata: `Patch` is added to the automatic CRUD
544585
* Symfony: generated route names and operation names changed, route naming can be changed directly within metadata
545586
* Doctrine: remove `@final` annotation from filters and mark them as `final`
546-
587+
547588
## v2.7.14
548589
549590
### Bug fixes

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ We strongly recommend the use of a scope on API Platform core.
118118

119119
On `api-platform/core` there are two kinds of tests: unit (`phpunit` through `simple-phpunit`) and integration tests (`behat`).
120120

121+
Note that we stopped using `prophesize` for new tests since 3.2, use `phpunit` stub system.
122+
121123
Both `simple-phpunit` and `behat` are development dependencies and should be available in the `vendor` directory.
122124

123125
#### PHPUnit and Coverage Generation

features/graphql/docs.feature

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Feature: Documentation support
2+
In order to play with GraphQL
3+
As a client software developer
4+
I want to reach the GraphQL documentation
5+
6+
Scenario: Retrieve the OpenAPI documentation
7+
Given I add "Accept" header equal to "text/html"
8+
And I send a "GET" request to "/graphql"
9+
Then the response status code should be 200
10+
And the header "Content-Type" should be equal to "text/html; charset=utf-8"

features/main/exception_to_status.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ Feature: Using exception_to_status config
3838
And I send a "DELETE" request to "/error_with_overriden_status/1"
3939
Then the response status code should be 403
4040
And the JSON node "status" should be equal to 403
41+
42+
@!mongodb
43+
Scenario: Get HTTP Exception headers
44+
When I add "Accept" header equal to "application/ld+json"
45+
And I send a "GET" request to "/issue5924"
46+
Then the response status code should be 429
47+
Then the header "retry-after" should be equal to 32

phpstan.neon.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ parameters:
2626
- src/Symfony/Bundle/DependencyInjection/Configuration.php
2727
# Templates for Maker
2828
- src/Symfony/Maker/Resources/skeleton
29+
- **vendor**
2930
earlyTerminatingMethodCalls:
3031
PHPUnit\Framework\Constraint\Constraint:
3132
- fail

src/Api/FilterInterface.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,44 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
interface FilterInterface extends \ApiPlatform\Metadata\FilterInterface
16+
/**
17+
* Filters applicable on a resource.
18+
*
19+
* @author Kévin Dunglas <[email protected]>
20+
*/
21+
interface FilterInterface
1722
{
23+
/**
24+
* Gets the description of this filter for the given resource.
25+
*
26+
* Returns an array with the filter parameter names as keys and array with the following data as values:
27+
* - property: the property where the filter is applied
28+
* - type: the type of the filter
29+
* - required: if this filter is required
30+
* - strategy (optional): the used strategy
31+
* - is_collection (optional): if this filter is for collection
32+
* - swagger (optional): additional parameters for the path operation,
33+
* e.g. 'swagger' => [
34+
* 'description' => 'My Description',
35+
* 'name' => 'My Name',
36+
* 'type' => 'integer',
37+
* ]
38+
* - openapi (optional): additional parameters for the path operation in the version 3 spec,
39+
* e.g. 'openapi' => [
40+
* 'description' => 'My Description',
41+
* 'name' => 'My Name',
42+
* 'schema' => [
43+
* 'type' => 'integer',
44+
* ]
45+
* ]
46+
* - schema (optional): schema definition,
47+
* e.g. 'schema' => [
48+
* 'type' => 'string',
49+
* 'enum' => ['value_1', 'value_2'],
50+
* ]
51+
* The description can contain additional data specific to a filter.
52+
*
53+
* @see \ApiPlatform\OpenApi\Factory\OpenApiFactory::getFiltersParameters
54+
*/
55+
public function getDescription(string $resourceClass): array;
1856
}

src/Api/FilterLocatorTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace ApiPlatform\Api;
1515

1616
use ApiPlatform\Exception\InvalidArgumentException;
17-
use ApiPlatform\Metadata\FilterInterface;
17+
use ApiPlatform\Metadata\FilterInterface as MetadataFilterInterface;
1818
use Psr\Container\ContainerInterface;
1919

2020
/**
@@ -45,7 +45,7 @@ private function setFilterLocator(?ContainerInterface $filterLocator, bool $allo
4545
/**
4646
* Gets a filter with a backward compatibility.
4747
*/
48-
private function getFilter(string $filterId): ?FilterInterface
48+
private function getFilter(string $filterId): null|FilterInterface|MetadataFilterInterface
4949
{
5050
if ($this->filterLocator && $this->filterLocator->has($filterId)) {
5151
return $this->filterLocator->get($filterId);

src/Api/IdentifiersExtractorInterface.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
class_exists(\ApiPlatform\Metadata\IdentifiersExtractorInterface::class);
16+
use ApiPlatform\Metadata\Exception\RuntimeException;
17+
use ApiPlatform\Metadata\Operation;
1718

18-
class_alias(
19-
\ApiPlatform\Metadata\IdentifiersExtractorInterface::class,
20-
__NAMESPACE__.'\IdentifiersExtractorInterface'
21-
);
22-
23-
if (false) { // @phpstan-ignore-line
24-
interface IdentifiersExtractorInterface extends \ApiPlatform\Metadata\IdentifiersExtractorInterface
25-
{
26-
}
19+
/**
20+
* Extracts identifiers for a given Resource according to the retrieved Metadata.
21+
*
22+
* @author Antoine Bluchet <[email protected]>
23+
*/
24+
interface IdentifiersExtractorInterface
25+
{
26+
/**
27+
* Finds identifiers from an Item (object).
28+
*
29+
* @throws RuntimeException
30+
*/
31+
public function getIdentifiersFromItem(object $item, Operation $operation = null, array $context = []): array;
2732
}

src/Api/IriConverterInterface.php

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,33 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
class_exists(\ApiPlatform\Metadata\IriConverterInterface::class);
16+
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
17+
use ApiPlatform\Metadata\Exception\ItemNotFoundException;
18+
use ApiPlatform\Metadata\Exception\RuntimeException;
19+
use ApiPlatform\Metadata\Operation;
1720

18-
class_alias(
19-
\ApiPlatform\Metadata\IriConverterInterface::class,
20-
__NAMESPACE__.'\IriConverterInterface'
21-
);
21+
/**
22+
* Converts item and resources to IRI and vice versa.
23+
*
24+
* @author Kévin Dunglas <[email protected]>
25+
*/
26+
interface IriConverterInterface
27+
{
28+
/**
29+
* Retrieves an item from its IRI.
30+
*
31+
* @throws InvalidArgumentException
32+
* @throws ItemNotFoundException
33+
*/
34+
public function getResourceFromIri(string $iri, array $context = [], Operation $operation = null): object;
2235

23-
if (false) { // @phpstan-ignore-line
24-
interface IriConverterInterface extends \ApiPlatform\Metadata\IriConverterInterface
25-
{
26-
}
36+
/**
37+
* Gets the IRI associated with the given item.
38+
*
39+
* @param object|class-string $resource
40+
*
41+
* @throws InvalidArgumentException
42+
* @throws RuntimeException
43+
*/
44+
public function getIriFromResource(object|string $resource, int $referenceType = UrlGeneratorInterface::ABS_PATH, Operation $operation = null, array $context = []): ?string;
2745
}

src/Api/ResourceClassResolverInterface.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,27 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
class_exists(\ApiPlatform\Metadata\ResourceClassResolverInterface::class);
16+
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
1717

18-
if (false) { // @phpstan-ignore-line
19-
interface ResourceClassResolverInterface extends \ApiPlatform\Metadata\ResourceClassResolverInterface
20-
{
21-
}
18+
/**
19+
* Guesses which resource is associated with a given object.
20+
*
21+
* @author Kévin Dunglas <[email protected]>
22+
*/
23+
interface ResourceClassResolverInterface
24+
{
25+
/**
26+
* Guesses the associated resource.
27+
*
28+
* @param string $resourceClass The expected resource class
29+
* @param bool $strict If true, value must match the expected resource class
30+
*
31+
* @throws InvalidArgumentException
32+
*/
33+
public function getResourceClass(mixed $value, string $resourceClass = null, bool $strict = false): string;
34+
35+
/**
36+
* Is the given class a resource class?
37+
*/
38+
public function isResourceClass(string $type): bool;
2239
}

src/Api/UriVariableTransformerInterface.php

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,27 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
interface UriVariableTransformerInterface extends \ApiPlatform\Metadata\UriVariableTransformerInterface
16+
use ApiPlatform\Exception\InvalidUriVariableException;
17+
18+
interface UriVariableTransformerInterface
1719
{
20+
/**
21+
* Transforms the value of a URI variable (identifier) to its type.
22+
*
23+
* @param mixed $value The URI variable value to transform
24+
* @param array $types The guessed type behind the URI variable
25+
* @param array $context Options available to the transformer
26+
*
27+
* @throws InvalidUriVariableException Occurs when the URI variable could not be transformed
28+
*/
29+
public function transform(mixed $value, array $types, array $context = []);
30+
31+
/**
32+
* Checks whether the value of a URI variable can be transformed to its type by this transformer.
33+
*
34+
* @param mixed $value The URI variable value to transform
35+
* @param array $types The types to which the URI variable value should be transformed
36+
* @param array $context Options available to the transformer
37+
*/
38+
public function supportsTransformation(mixed $value, array $types, array $context = []): bool;
1839
}

src/Api/UriVariablesConverterInterface.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,24 @@
1313

1414
namespace ApiPlatform\Api;
1515

16-
class_exists(\ApiPlatform\Metadata\UriVariablesConverterInterface::class);
16+
use ApiPlatform\Metadata\Exception\InvalidIdentifierException;
1717

18-
class_alias(
19-
\ApiPlatform\Metadata\UriVariablesConverterInterface::class,
20-
__NAMESPACE__.'\UriVariablesConverterInterface'
21-
);
22-
23-
if (false) { // @phpstan-ignore-line
24-
interface UriVariablesConverterInterface extends \ApiPlatform\Metadata\UriVariablesConverterInterface
25-
{
26-
}
18+
/**
19+
* Identifier converter.
20+
*
21+
* @author Antoine Bluchet <[email protected]>
22+
*/
23+
interface UriVariablesConverterInterface
24+
{
25+
/**
26+
* Takes an array of strings representing URI variables (identifiers) and transform their values to the expected type.
27+
*
28+
* @param array $data URI variables to convert to PHP values
29+
* @param string $class The class to which the URI variables belong to
30+
*
31+
* @throws InvalidIdentifierException
32+
*
33+
* @return array Array indexed by identifiers properties with their values denormalized
34+
*/
35+
public function convert(array $data, string $class, array $context = []): array;
2736
}

0 commit comments

Comments
 (0)