This commit is contained in:
2025-10-31 01:19:01 +01:00
parent 5b5916ff92
commit fa43bc749e
16 changed files with 878 additions and 872 deletions
+45
View File
@@ -58,6 +58,12 @@ struct CorrespondentChangeset<'a> {
metadata: Option<&'a Value>,
}
#[utoipa::path(
get,
path = "/api/correspondents",
responses((status = 200, description = "Correspondents", body = [CorrespondentSummary])),
tag = "Correspondents"
)]
pub async fn list_correspondents(
TenantScopedConn {
mut conn,
@@ -90,6 +96,13 @@ pub async fn list_correspondents(
response.into_json()
}
#[utoipa::path(
post,
path = "/api/correspondents",
request_body = CreateCorrespondentRequest,
responses((status = 200, description = "Correspondent created", body = CorrespondentSummary)),
tag = "Correspondents"
)]
pub async fn create_correspondent(
TenantScopedConn {
mut conn,
@@ -132,6 +145,14 @@ pub async fn create_correspondent(
build_summary(correspondent, 0).into_json()
}
#[utoipa::path(
patch,
path = "/api/correspondents/{id}",
params(("id" = Uuid, Path, description = "Correspondent ID")),
request_body = UpdateCorrespondentRequest,
responses((status = 200, description = "Correspondent updated", body = CorrespondentSummary)),
tag = "Correspondents"
)]
pub async fn update_correspondent(
Path(correspondent_id): Path<Uuid>,
TenantScopedConn {
@@ -206,6 +227,13 @@ pub async fn update_correspondent(
build_summary(updated, usage).into_json()
}
#[utoipa::path(
delete,
path = "/api/correspondents/{id}",
params(("id" = Uuid, Path, description = "Correspondent ID")),
responses((status = 204, description = "Correspondent deleted")),
tag = "Correspondents"
)]
pub async fn delete_correspondent(
Path(correspondent_id): Path<Uuid>,
TenantScopedConn {
@@ -269,3 +297,20 @@ fn load_usage_for_correspondent(
Ok(total)
}
#[derive(utoipa::OpenApi)]
#[openapi(
paths(
crate::routes::correspondents::list_correspondents,
crate::routes::correspondents::create_correspondent,
crate::routes::correspondents::update_correspondent,
crate::routes::correspondents::delete_correspondent
),
components(schemas(
crate::routes::correspondents::CorrespondentSummary,
crate::routes::correspondents::CorrespondentUsage,
crate::routes::correspondents::CreateCorrespondentRequest,
crate::routes::correspondents::UpdateCorrespondentRequest
))
)]
pub struct CorrespondentsApiDoc;