From fd8fcf409287718d537e7dc078c49d586b6f4479 Mon Sep 17 00:00:00 2001 From: Antoine Bluchet Date: Tue, 26 Jan 2021 09:58:34 +0100 Subject: [PATCH 1/5] fix #3980 TraceableDataPersister supports called without context (#3983) * fix #3980 DataPersister supports called without context * Update tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php Co-authored-by: Maks Rafalko Co-authored-by: Maks Rafalko --- .../DataPersister/TraceableChainDataPersister.php | 2 +- .../TraceableChainDataPersisterTest.php | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersister.php b/src/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersister.php index 801d12e82d7..a85a79f2219 100644 --- a/src/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersister.php +++ b/src/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersister.php @@ -73,7 +73,7 @@ private function tracePersisters($data, array $context = []) $found = false; foreach ($this->persisters as $persister) { if ( - ($this->persistersResponse[\get_class($persister)] = $found ? false : $persister->supports($data)) + ($this->persistersResponse[\get_class($persister)] = $found ? false : $persister->supports($data, $context)) && !($persister instanceof ResumableDataPersisterInterface && $persister->resumable()) && !$found ) { diff --git a/tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php b/tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php index 4a231cd2fea..bb4cea1ef56 100644 --- a/tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php +++ b/tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php @@ -60,6 +60,16 @@ public function testRemove($persister, $expected) $this->assertSame($expected, array_values($result)); } + public function testSupports() { + $context = ['ok' => true]; + $persister = $this->prophesize(DataPersisterInterface::class); + $persister->supports('', $context)->willReturn(true)->shouldBeCalled(); + $chain = new ChainDataPersister([$persister->reveal()]); + $persister->persist('', $context)->shouldBeCalled(); + $dataPersister = new TraceableChainDataPersister($chain); + $dataPersister->persist('', $context); + } + public function dataPersisterProvider(): iterable { yield [ @@ -163,7 +173,7 @@ public function persist($data) public function remove($data) { } - }, + } ]), [true, false, true], ]; From f5d191dade2239c572b76367ade158eabb8b2dbe Mon Sep 17 00:00:00 2001 From: Antoine Bluchet Date: Tue, 26 Jan 2021 16:50:31 +0100 Subject: [PATCH 2/5] Fix cs (#3984) --- .../Bundle/DataPersister/TraceableChainDataPersisterTest.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php b/tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php index bb4cea1ef56..f723a501ea5 100644 --- a/tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php +++ b/tests/Bridge/Symfony/Bundle/DataPersister/TraceableChainDataPersisterTest.php @@ -60,7 +60,8 @@ public function testRemove($persister, $expected) $this->assertSame($expected, array_values($result)); } - public function testSupports() { + public function testSupports() + { $context = ['ok' => true]; $persister = $this->prophesize(DataPersisterInterface::class); $persister->supports('', $context)->willReturn(true)->shouldBeCalled(); @@ -173,7 +174,7 @@ public function persist($data) public function remove($data) { } - } + }, ]), [true, false, true], ]; From e559a198284549360b6e9274290c0616f874f0c9 Mon Sep 17 00:00:00 2001 From: Antoine Bluchet Date: Tue, 26 Jan 2021 22:12:36 +0100 Subject: [PATCH 3/5] Fix mongodb tests (#3988) --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d268056ee9..85fa56ab18d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -522,9 +522,9 @@ jobs: - name: Update project dependencies run: | composer update --no-interaction --no-progress --ansi - composer why doctrine/reflection - # - name: Require Symfony Uid - # run: composer require symfony/uid --dev --no-interaction --no-progress --ansi + # composer why doctrine/reflection + - name: Require Symfony Uid + run: composer require symfony/uid --dev --no-interaction --no-progress --ansi - name: Install PHPUnit run: vendor/bin/simple-phpunit --version - name: Clear test app cache From 24a4a7c760fa18799be5bb89a6040c1e07745bac Mon Sep 17 00:00:00 2001 From: Quentin Fahrner Date: Thu, 28 Jan 2021 04:21:37 -0500 Subject: [PATCH 4/5] Fix Swagger link in comments (#3990) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: rename master brand to main * Fix Swagger link in comments Fixing the link "https://api-platform.com/docs/core/swagger/" that leads to a 404 Co-authored-by: Kévin Dunglas --- README.md | 7 +++---- composer.json | 2 +- src/Annotation/ApiResource.php | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1fcbdb4704e..1a1f9f86358 100644 --- a/README.md +++ b/README.md @@ -9,11 +9,10 @@ It natively supports popular open formats including [JSON for Linked Data (JSON- Build a working and fully-featured CRUD API in minutes. Leverage the awesome features of the tool to develop complex and high performance API-first projects. Extend or override everything you want. -[![GitHub Actions](https://github.com/api-platform/core/workflows/CI/badge.svg?branch=master)](https://github.com/api-platform/core/actions?query=workflow%3ACI+branch%3Amaster) -[![AppVeyor](https://ci.appveyor.com/api/projects/status/grwuyprts3wdqx5l/branch/master?svg=true)](https://ci.appveyor.com/project/dunglas/dunglasapibundle/branch/master) -[![Codecov](https://codecov.io/gh/api-platform/core/branch/master/graph/badge.svg)](https://codecov.io/gh/api-platform/core/branch/master) +[![GitHub Actions](https://github.com/api-platform/core/workflows/CI/badge.svg?branch=main)](https://github.com/api-platform/core/actions?query=workflow%3ACI+branch%3Amain) +[![Codecov](https://codecov.io/gh/api-platform/core/branch/main/graph/badge.svg)](https://codecov.io/gh/api-platform/core/branch/main) [![SymfonyInsight](https://insight.symfony.com/projects/92d78899-946c-4282-89a3-ac92344f9a93/mini.svg)](https://insight.symfony.com/projects/92d78899-946c-4282-89a3-ac92344f9a93) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/api-platform/core/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/api-platform/core/?branch=master) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/api-platform/core/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/api-platform/core/?branch=main) ## Documentation diff --git a/composer.json b/composer.json index 83d4a7dc37f..a4a2e4fa763 100644 --- a/composer.json +++ b/composer.json @@ -124,7 +124,7 @@ }, "extra": { "branch-alias": { - "dev-master": "2.6.x-dev" + "dev-main": "2.7.x-dev" }, "symfony": { "require": "^3.4 || ^4.4 || ^5.1" diff --git a/src/Annotation/ApiResource.php b/src/Annotation/ApiResource.php index 1bee3858161..a591557e10b 100644 --- a/src/Annotation/ApiResource.php +++ b/src/Annotation/ApiResource.php @@ -148,7 +148,7 @@ final class ApiResource * @param bool|array $mercure https://api-platform.com/docs/core/mercure * @param bool $messenger https://api-platform.com/docs/core/messenger/#dispatching-a-resource-through-the-message-bus * @param array $normalizationContext https://api-platform.com/docs/core/serialization/#using-serialization-groups - * @param array $openapiContext https://api-platform.com/docs/core/swagger/#using-the-openapi-and-swagger-contexts + * @param array $openapiContext https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts * @param array $order https://api-platform.com/docs/core/default-order/#overriding-default-order * @param string|false $output https://api-platform.com/docs/core/dto/#specifying-an-input-or-an-output-data-representation * @param bool $paginationClientEnabled https://api-platform.com/docs/core/pagination/#for-a-specific-resource-1 @@ -167,7 +167,7 @@ final class ApiResource * @param string $securityPostDenormalizeMessage https://api-platform.com/docs/core/security/#configuring-the-access-control-error-message * @param bool $stateless * @param string $sunset https://api-platform.com/docs/core/deprecations/#setting-the-sunset-http-header-to-indicate-when-a-resource-or-an-operation-will-be-removed - * @param array $swaggerContext https://api-platform.com/docs/core/swagger/#using-the-openapi-and-swagger-contexts + * @param array $swaggerContext https://api-platform.com/docs/core/openapi/#using-the-openapi-and-swagger-contexts * @param array $validationGroups https://api-platform.com/docs/core/validation/#using-validation-groups * @param int $urlGenerationStrategy * From 662e69a6be45a20262f4bb6e6ebea9eeb65eb15d Mon Sep 17 00:00:00 2001 From: "stiff.roy" Date: Fri, 29 Jan 2021 02:26:08 +0100 Subject: [PATCH 5/5] Fix: OpenApi: Sorting the resources and schemas --- src/OpenApi/Model/Components.php | 2 ++ src/OpenApi/Model/Paths.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/OpenApi/Model/Components.php b/src/OpenApi/Model/Components.php index 1035ab1d7f0..3191e4a7da6 100644 --- a/src/OpenApi/Model/Components.php +++ b/src/OpenApi/Model/Components.php @@ -38,6 +38,8 @@ public function __construct(\ArrayObject $schemas = null, \ArrayObject $response $this->securitySchemes = $securitySchemes; $this->links = $links; $this->callbacks = $callbacks; + + $this->schemas->ksort(); } public function getSchemas(): ?\ArrayObject diff --git a/src/OpenApi/Model/Paths.php b/src/OpenApi/Model/Paths.php index 80829b3d876..f9946ec8883 100644 --- a/src/OpenApi/Model/Paths.php +++ b/src/OpenApi/Model/Paths.php @@ -15,7 +15,7 @@ final class Paths { - private $paths; + private $paths = []; public function addPath(string $path, PathItem $pathItem) { @@ -29,6 +29,8 @@ public function getPath(string $path): ?PathItem public function getPaths(): array { - return $this->paths ?? []; + ksort($this->paths); + + return $this->paths; } }