[Router] Refactor protocol definitions: split spec.rs into modular files (#11677)

Co-authored-by: Chang Su <chang.s.su@oracle.com>
This commit is contained in:
Keyang Ru
2025-10-16 13:44:44 -07:00
committed by GitHub
parent 86b04d25b3
commit 4c9bcb9d56
56 changed files with 2939 additions and 2914 deletions

View File

@@ -83,20 +83,11 @@ where
// Then, automatically validate the data
data.validate().map_err(|validation_errors| {
// Extract the first error message from the validation errors
let error_message = validation_errors
.field_errors()
.values()
.flat_map(|errors| errors.iter())
.find_map(|e| e.message.as_ref())
.map(|m| m.to_string())
.unwrap_or_else(|| "Validation failed".to_string());
(
StatusCode::BAD_REQUEST,
Json(json!({
"error": {
"message": error_message,
"message": validation_errors.to_string(),
"type": "invalid_request_error",
"code": 400
}