mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 01:08:26 +00:00 
			
		
		
		
	send 400 bad request on invalid json
This commit is contained in:
		| @@ -10,6 +10,8 @@ use Chill\MainBundle\Serializer\Model\Collection; | ||||
| use Chill\MainBundle\Pagination\PaginatorInterface; | ||||
| use Symfony\Component\Serializer\Normalizer\AbstractNormalizer; | ||||
| use Symfony\Component\Validator\ConstraintViolationListInterface; | ||||
| use Symfony\Component\Serializer\Exception\NotEncodableValueException; | ||||
| use Symfony\Component\HttpFoundation\Exception\BadRequestException; | ||||
|  | ||||
| class ApiController extends AbstractCRUDController | ||||
| { | ||||
| @@ -122,8 +124,13 @@ class ApiController extends AbstractCRUDController | ||||
|         if ($response instanceof 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); | ||||
|  | ||||
|         $response = $this->onAfterValidation($action, $request, $_format, $entity, $errors); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user