From 399863377f46ce4fbbd5853dc2aff33167185b21 Mon Sep 17 00:00:00 2001 From: Mauro Cassani Date: Tue, 23 Dec 2025 15:25:18 +0100 Subject: [PATCH] [API] Validation errors payload --- lib/Controller/API/V3/PayableRateController.php | 8 +++++++- lib/Controller/API/V3/QAModelTemplateController.php | 8 +++++++- .../JSONSchema/Errors/JSONValidatorException.php | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/Controller/API/V3/PayableRateController.php b/lib/Controller/API/V3/PayableRateController.php index 81beb7aa19..59c8abcb5e 100644 --- a/lib/Controller/API/V3/PayableRateController.php +++ b/lib/Controller/API/V3/PayableRateController.php @@ -219,8 +219,14 @@ public function validate(): Response $this->response->code($code); + $formattedErrors = []; + + foreach ($errors as $error) { + $formattedErrors[] = $error->getFormattedError("payable_rate"); + } + return $this->response->json([ - 'errors' => $errors + 'errors' => $formattedErrors ]); } catch (Exception $exception) { $errorCode = $exception->getCode() >= 400 ? $exception->getCode() : 500; diff --git a/lib/Controller/API/V3/QAModelTemplateController.php b/lib/Controller/API/V3/QAModelTemplateController.php index fbccf3ddea..b39f3b8e99 100644 --- a/lib/Controller/API/V3/QAModelTemplateController.php +++ b/lib/Controller/API/V3/QAModelTemplateController.php @@ -243,8 +243,14 @@ public function validate(): Response $this->response->code($code); + $formattedErrors = []; + + foreach ($errors as $error) { + $formattedErrors[] = $error->getFormattedError("qa_model_template"); + } + return $this->response->json([ - 'errors' => $errors + 'errors' => $formattedErrors ]); } catch (Exception $exception) { $this->response->code(500); diff --git a/lib/Utils/Validator/JSONSchema/Errors/JSONValidatorException.php b/lib/Utils/Validator/JSONSchema/Errors/JSONValidatorException.php index f8a6b94916..34df3e69e7 100644 --- a/lib/Utils/Validator/JSONSchema/Errors/JSONValidatorException.php +++ b/lib/Utils/Validator/JSONSchema/Errors/JSONValidatorException.php @@ -33,6 +33,7 @@ public function getFormattedError(string $context): array { return [ 'node' => $this->error->dataPointer, + 'schemaPointers' => $this->error->schemaPointers, 'schema' => '/api/v3/' . $context . '/schema', 'error' => $this->error->error, ];