mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
send 400 bad request on invalid json
This commit is contained in:
parent
f8e91c325d
commit
f7a807473d
@ -10,6 +10,8 @@ use Chill\MainBundle\Serializer\Model\Collection;
|
|||||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||||
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
use Symfony\Component\Validator\ConstraintViolationListInterface;
|
||||||
|
use Symfony\Component\Serializer\Exception\NotEncodableValueException;
|
||||||
|
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||||
|
|
||||||
class ApiController extends AbstractCRUDController
|
class ApiController extends AbstractCRUDController
|
||||||
{
|
{
|
||||||
@ -122,8 +124,13 @@ class ApiController extends AbstractCRUDController
|
|||||||
if ($response instanceof Response) {
|
if ($response instanceof Response) {
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$entity = $this->deserialize($action, $request, $_format, $entity);
|
||||||
|
} catch (NotEncodableValueException $e) {
|
||||||
|
throw new BadRequestException("invalid json", 400, $e);
|
||||||
|
}
|
||||||
|
|
||||||
$entity = $this->deserialize($action, $request, $_format, $entity);
|
|
||||||
$errors = $this->validate($action, $request, $_format, $entity);
|
$errors = $this->validate($action, $request, $_format, $entity);
|
||||||
|
|
||||||
$response = $this->onAfterValidation($action, $request, $_format, $entity, $errors);
|
$response = $this->onAfterValidation($action, $request, $_format, $entity, $errors);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user