Skip to content

Commit

Permalink
doc: error guide remove useless configuration (#6712)
Browse files Browse the repository at this point in the history
Co-authored-by: Kévin Dunglas <[email protected]>
  • Loading branch information
soyuka and dunglas authored Oct 10, 2024
1 parent fbb53e5 commit 0a689b3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions docs/guides/error-resource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -47,6 +40,8 @@ public function getInstance(): ?string
{
return null;
}

public string $myCustomField = 'I usually prefer coffee.';
}

use ApiPlatform\Metadata\ApiResource;
Expand Down Expand Up @@ -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.'
]);
}
}
Expand Down

0 comments on commit 0a689b3

Please sign in to comment.