hive-c0re: annotate remaining dashboard routes with utoipa
This commit is contained in:
parent
8ebefeb0d5
commit
582ebe5eee
21 changed files with 738 additions and 45 deletions
|
|
@ -12,12 +12,13 @@ use axum::{
|
|||
response::{IntoResponse, Response},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use utoipa::ToSchema;
|
||||
|
||||
use problem_details::ProblemDetails;
|
||||
|
||||
use super::{AppState, error_response};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[derive(Deserialize, ToSchema)]
|
||||
pub(super) struct AnswerForm {
|
||||
answer: String,
|
||||
}
|
||||
|
|
@ -37,6 +38,20 @@ fn with_cors(resp: impl IntoResponse) -> Response {
|
|||
resp
|
||||
}
|
||||
|
||||
/// `POST /answer-question/{id}` — record the operator's answer and
|
||||
/// notify the asker.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/answer-question/{id}",
|
||||
params(("id" = i64, Path, description = "question row id")),
|
||||
request_body(content = AnswerForm, content_type = "application/x-www-form-urlencoded"),
|
||||
responses(
|
||||
(status = 200, description = "answered", body = String),
|
||||
(status = 400, description = "empty answer"),
|
||||
(status = 500, description = "answer failed (already answered, unknown id, ...)"),
|
||||
),
|
||||
tag = "questions"
|
||||
)]
|
||||
pub(super) async fn post_answer_question(
|
||||
State(state): State<AppState>,
|
||||
AxumPath(id): AxumPath<i64>,
|
||||
|
|
@ -85,6 +100,18 @@ pub(super) async fn post_answer_question(
|
|||
/// so it can fall back on whatever default it had. Same code path as
|
||||
/// a real answer — just lets the operator close the loop instead of
|
||||
/// letting the question dangle forever.
|
||||
/// `POST /cancel-question/{id}` — resolve a pending question with the
|
||||
/// `[cancelled]` sentinel answer.
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/cancel-question/{id}",
|
||||
params(("id" = i64, Path, description = "question row id")),
|
||||
responses(
|
||||
(status = 200, description = "cancelled", body = String),
|
||||
(status = 500, description = "cancel failed (already answered, unknown id, ...)"),
|
||||
),
|
||||
tag = "questions"
|
||||
)]
|
||||
pub(super) async fn post_cancel_question(
|
||||
State(state): State<AppState>,
|
||||
AxumPath(id): AxumPath<i64>,
|
||||
|
|
|
|||
Loading…
Reference in a new issue