G: G1 REST spec derive the OpenAPI document from the handlers

This commit is contained in:
ari committed 2026-10-20 15:54:13 -04:00
1 parent 5f4a0583f3
commit 3d8e840427
13 files changed
+1347 -20

No files matched your search

+15 -1
View File
@@ -7,13 +7,27 @@
use axum::routing::get;
use axum::{Json, Router};
use crate::openapi::Health;
use crate::state::AppState;
pub fn routes() -> Router<AppState> {
Router::new().route("/ping", get(ping))
}
async fn ping() -> Json<serde_json::Value> {
#[utoipa::path(
get,
path = "/api/v1/ping",
operation_id = "ping",
tag = "health",
summary = "Authenticated liveness",
description = "Cheap authenticated check. A consolidator calls it to prove that the API \
answers with its credential: a 401 still means the API is running.",
responses(
(status = 200, body = Health, description = "The API is running and the token is valid"),
(status = 401, body = crate::openapi::ErrorBody, description = "Missing or unknown bearer token"),
)
)]
pub(crate) async fn ping() -> Json<serde_json::Value> {
Json(serde_json::json!({
"status": "ok",
"version": env!("CARGO_PKG_VERSION"),