Skip to content

Commit 0a689b3

Browse files
soyukadunglas
andauthored
doc: error guide remove useless configuration (#6712)
Co-authored-by: Kévin Dunglas <[email protected]>
1 parent fbb53e5 commit 0a689b3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/guides/error-resource.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@
77
// tags: design, state
88
// ---
99

10-
// Note that we use the following configuration:
11-
// ```
12-
// api_platform:
13-
// defaults:
14-
// rfc_7807_compliant_errors: true
15-
// ```
16-
1710
namespace App\ApiResource {
1811
use ApiPlatform\Metadata\ErrorResource;
1912
use ApiPlatform\Metadata\Exception\ProblemExceptionInterface;
@@ -25,12 +18,12 @@ class MyDomainException extends \Exception implements ProblemExceptionInterface
2518
{
2619
public function getType(): string
2720
{
28-
return 'teapot';
21+
return '/errors/418';
2922
}
3023

3124
public function getTitle(): ?string
3225
{
33-
return null;
26+
return 'Teapot error';
3427
}
3528

3629
public function getStatus(): ?int
@@ -47,6 +40,8 @@ public function getInstance(): ?string
4740
{
4841
return null;
4942
}
43+
44+
public string $myCustomField = 'I usually prefer coffee.';
5045
}
5146

5247
use ApiPlatform\Metadata\ApiResource;
@@ -90,7 +85,12 @@ public function testBookDoesNotExists(): void
9085
// you can override this by looking at the [Error Provider guide](/docs/guides/error-provider).
9186
$this->assertResponseStatusCodeSame(418);
9287
$this->assertJsonContains([
88+
'@id' => '/my_domain_exceptions',
89+
'@type' => 'MyDomainException',
90+
'type' => '/errors/418',
91+
'title' => 'Teapot error',
9392
'detail' => 'I am teapot',
93+
'myCustomField' => 'I usually prefer coffee.'
9494
]);
9595
}
9696
}

0 commit comments

Comments
 (0)