[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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user