refactor(api): descriptive closure params; exhaustive FieldError match; field-endpoint auth tests
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -377,22 +377,22 @@ pub(crate) async fn list_field_definitions(
|
||||
|
||||
Ok(Json(
|
||||
defs.into_iter()
|
||||
.map(|d| {
|
||||
let (data_type, vocabulary_id, authority_kind) = d.field_type.to_parts();
|
||||
.map(|def| {
|
||||
let (data_type, vocabulary_id, authority_kind) = def.field_type.to_parts();
|
||||
|
||||
FieldDefinitionView {
|
||||
key: d.key,
|
||||
key: def.key,
|
||||
data_type: data_type.to_owned(),
|
||||
vocabulary_id: vocabulary_id.map(|v| v.to_string()),
|
||||
authority_kind: authority_kind.map(|k| k.as_str().to_owned()),
|
||||
required: d.required,
|
||||
group: d.group_key,
|
||||
labels: d
|
||||
vocabulary_id: vocabulary_id.map(|vocab_id| vocab_id.to_string()),
|
||||
authority_kind: authority_kind.map(|kind| kind.as_str().to_owned()),
|
||||
required: def.required,
|
||||
group: def.group_key,
|
||||
labels: def
|
||||
.labels
|
||||
.into_iter()
|
||||
.map(|l| LabelView {
|
||||
lang: l.lang,
|
||||
label: l.label,
|
||||
.map(|label| LabelView {
|
||||
lang: label.lang,
|
||||
label: label.label,
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
@@ -447,7 +447,9 @@ pub(crate) async fn set_fields(
|
||||
}
|
||||
Err(db::catalog::FieldError::ObjectNotFound) => Err(StatusCode::NOT_FOUND),
|
||||
Err(db::catalog::FieldError::Db(_)) => Err(StatusCode::INTERNAL_SERVER_ERROR),
|
||||
Err(_) => Err(StatusCode::UNPROCESSABLE_ENTITY),
|
||||
Err(db::catalog::FieldError::UnknownField(_)) => Err(StatusCode::UNPROCESSABLE_ENTITY),
|
||||
Err(db::catalog::FieldError::TypeMismatch { .. }) => Err(StatusCode::UNPROCESSABLE_ENTITY),
|
||||
Err(db::catalog::FieldError::Unresolved { .. }) => Err(StatusCode::UNPROCESSABLE_ENTITY),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user