feat(api): add health probes, OpenAPI doc, and router

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-02 00:58:29 +02:00
parent 8da3eefdce
commit b9acc03761
4 changed files with 180 additions and 0 deletions
+25
View File
@@ -0,0 +1,25 @@
use axum::{Json, Router, extract::State, routing::get};
use utoipa::OpenApi;
use crate::{AppState, health};
#[derive(OpenApi)]
#[openapi(
paths(health::live, health::ready),
components(schemas(health::Live, health::Ready)),
info(title = "Collection Management System", version = "0.0.0")
)]
struct ApiDoc;
/// Serve the OpenAPI document, overriding the title from runtime config so the
/// product name is never hardcoded.
async fn openapi_json(State(state): State<AppState>) -> Json<utoipa::openapi::OpenApi> {
let mut doc = ApiDoc::openapi();
doc.info.title = state.app_name.clone();
Json(doc)
}
/// OpenAPI routes, parameterized over [`AppState`].
pub(crate) fn routes() -> Router<AppState> {
Router::new().route("/api-docs/openapi.json", get(openapi_json))
}