phpro / api-problem-bundle Goto Github PK
View Code? Open in Web Editor NEWRFC7807 Problem details integration for Symfony
License: MIT License
RFC7807 Problem details integration for Symfony
License: MIT License
Would it be possible to limit the execution of the transformation to a route regular expression like ^/api/
? So the transformation of the exceptions wouldn't occur on other places of the application which sometimes might throw an HttpException when accepting application/json but shouldn't be transformed.
This might be usefull for some applications which are not yet fully based on api's, or for some who want to migrate to newly structured api's
a priority from -5 should be better, because then, the "logKernelException()" call from symfony would not be intercepted.
------- ------------------------------------------------------------------------------------------- ----------
Order Callable Priority
------- ------------------------------------------------------------------------------------------- ----------
#2 Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException() 0
#3 Symfony\Component\HttpKernel\EventListener\ExceptionListener::logKernelException() 0
#4 Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener::onException() 0
#5 Phpro\ApiProblemBundle\EventListener\JsonApiProblemExceptionListener::onKernelException() -5
#6 Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelException() -64
#7 Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException() -128
#8 Symfony\Component\HttpKernel\EventListener\ExceptionListener::onKernelException() -2048
------- ------------------------------------------------------------------------------------------- ----------
console debug:event-dispatcher kernel.exception
It would be great to see an update for Symfony 5!
Q | A |
---|---|
BC Break | no |
Version | 1.4.0 |
Updating to symfony 6.0 gives a compile error in ApiProblemHttpException. The return types are missing in the code.
Symfony Validator component has a built in feature to normalize a ConstraintViolationListInterface
to an RFC7807 output. However, you need to do this by returning this yourself like so:
# IndexController.php
public function index(ValidatorInterface $validator)
{
$errors = $validator->validate(...);
return $this->json($errors, 400);
}
It would be much nicer to throw an exception, because in the above example, it is very easy to mis the response status. And with an exception it doesn't.
Maybe something like:
throw new ApiValidationException($errors);
Or does this package already has a solution for it?
I am concerned with random exception messages being revealed in the details field by default.
For example, today I've met Symfony's exception was thrown by internal logic of Translations engine with the text Unable to write to the "/var/task/var/cache/lambda/translations" directory.
which reveals the internal structure of the project (and the fact project uses Symfony) which could be considered as a security breach.
My proposition is to not show exception's message in details
field by default in production environment.
The type of expected answer should be used rather than the type of the request body content type to define whether to use the library from what I understand.
For instance, say you have a get request: there is no need for a Content-Type, and I believe a Get request should never have a body, hence no content-type.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.