From 0a689b33265328247d88a597b68d21e0a36ec064 Mon Sep 17 00:00:00 2001 From: Antoine Bluchet Date: Thu, 10 Oct 2024 16:49:00 +0200 Subject: [PATCH] doc: error guide remove useless configuration (#6712) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Kévin Dunglas --- docs/guides/error-resource.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/guides/error-resource.php b/docs/guides/error-resource.php index 8ce945df841..aee265e2831 100644 --- a/docs/guides/error-resource.php +++ b/docs/guides/error-resource.php @@ -7,13 +7,6 @@ // tags: design, state // --- -// Note that we use the following configuration: -// ``` -// api_platform: -// defaults: -// rfc_7807_compliant_errors: true -// ``` - namespace App\ApiResource { use ApiPlatform\Metadata\ErrorResource; use ApiPlatform\Metadata\Exception\ProblemExceptionInterface; @@ -25,12 +18,12 @@ class MyDomainException extends \Exception implements ProblemExceptionInterface { public function getType(): string { - return 'teapot'; + return '/errors/418'; } public function getTitle(): ?string { - return null; + return 'Teapot error'; } public function getStatus(): ?int @@ -47,6 +40,8 @@ public function getInstance(): ?string { return null; } + + public string $myCustomField = 'I usually prefer coffee.'; } use ApiPlatform\Metadata\ApiResource; @@ -90,7 +85,12 @@ public function testBookDoesNotExists(): void // you can override this by looking at the [Error Provider guide](/docs/guides/error-provider). $this->assertResponseStatusCodeSame(418); $this->assertJsonContains([ + '@id' => '/my_domain_exceptions', + '@type' => 'MyDomainException', + 'type' => '/errors/418', + 'title' => 'Teapot error', 'detail' => 'I am teapot', + 'myCustomField' => 'I usually prefer coffee.' ]); } }