forked from api-platform/core
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: errors without compatibility flag
- Loading branch information
Showing
12 changed files
with
115 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
tests/Fixtures/TestBundle/ApiResource/ValidationExceptionProblem.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource; | ||
|
||
use ApiPlatform\Metadata\Post; | ||
use ApiPlatform\Symfony\Validator\Exception\ValidationException; | ||
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; | ||
use Symfony\Component\Validator\ConstraintViolationList; | ||
|
||
#[Post(read: true, provider: [ValidationExceptionProblem::class, 'provide'])] | ||
#[Post(uriTemplate: '/exception_problems', read: true, provider: [ValidationExceptionProblem::class, 'provideException'])] | ||
#[Post(uriTemplate: '/exception_problems_with_compatibility', read: true, provider: [ValidationExceptionProblem::class, 'provideException'], extraProperties: ['rfc_7807_compliant_errors' => false])] | ||
class ValidationExceptionProblem | ||
{ | ||
public static function provide(): void | ||
{ | ||
throw new ValidationException(new ConstraintViolationList()); | ||
} | ||
|
||
public static function provideException(): void | ||
{ | ||
throw new BadRequestHttpException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,7 @@ | |
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Event\ResponseEvent; | ||
use Symfony\Component\HttpKernel\HttpKernelInterface; | ||
use Symfony\Component\WebLink\GenericLinkProvider; | ||
use Symfony\Component\WebLink\HttpHeaderSerializer; | ||
use Symfony\Component\WebLink\Link; | ||
|
||
/** | ||
* @author Kévin Dunglas <[email protected]> | ||
|
@@ -49,13 +47,12 @@ public function testAddLinkHeader(string $expected, Request $request): void | |
|
||
$listener = new AddLinkHeaderListener($urlGenerator->reveal()); | ||
$listener->onKernelResponse($event); | ||
$this->assertSame($expected, (new HttpHeaderSerializer())->serialize($request->attributes->get('_links')->getLinks())); | ||
$this->assertSame($expected, (new HttpHeaderSerializer())->serialize($request->attributes->get('_api_platform_links')->getLinks())); | ||
} | ||
|
||
public static function provider(): \Iterator | ||
{ | ||
yield ['<http://example.com/docs>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"', new Request()]; | ||
yield ['<https://demo.mercure.rocks>; rel="mercure",<http://example.com/docs>; rel="http://www.w3.org/ns/hydra/core#apiDocumentation"', new Request([], [], ['_links' => new GenericLinkProvider([new Link('mercure', 'https://demo.mercure.rocks')])])]; | ||
} | ||
|
||
public function testSkipWhenPreflightRequest(): void | ||
|
@@ -75,6 +72,6 @@ public function testSkipWhenPreflightRequest(): void | |
$listener = new AddLinkHeaderListener($urlGenerator->reveal()); | ||
$listener->onKernelResponse($event); | ||
|
||
$this->assertFalse($request->attributes->has('_links')); | ||
$this->assertFalse($request->attributes->has('_api_platform_links')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters