core
core copied to clipboard
feat(openapi): add error resources schemes
| Q | A |
|---|---|
| Branch? | main |
| Tickets | Closes #6003 |
| License | MIT |
| Doc PR | api-platform/docs#TODO |
Allow linking ErrorResources to ApiResources to automatically generate openapi documentation for errors:
#[ApiResource(operations: [
new GetCollection(errors: [MyDomainException::class])
])]
class Greeting
{
...
}
with the following Exception (currently needs to be an ErrorResource and to implement ProblemExceptionInterface):
#[ErrorResource]
class MyDomainException extends \Exception implements ProblemExceptionInterface
{
public function getType(): string
{
return 'Teapot';
}
public function getTitle(): ?string
{
return null;
}
public function getStatus(): ?int
{
return 418;
}
public function getDetail(): ?string
{
return 'My specific Domain Exception';
}
public function getInstance(): ?string
{
return null;
}
}
would allow the following:
Do you think it might be an interesting feature ?
There might still be a few things I am not too familiar with, any advice is more than welcome !
This is nuts! Love it! Will review shortly.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Please don't close this, this is a much needed feature.
I'm so sorry I completely forgot about this, I'll get back to it ASAP
Cool feature!
Many thanks @JacquesDurand ! We need some documentation for that awesome feature!