From 1f56f7fcbb0934ac8e2208401dc62102e9caa630 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sat, 3 Oct 2026 13:14:47 +0000 Subject: Document ApiError 500 on / and /version, add README example. * src/lib.rs (hello_world)[utoipa::path]: Add 500, body ApiError. (version)[utoipa::path]: Likewise. Neither handler has a failure path today (no database access, no I/O); this documents the same error contract as /species and /species/{species} in /openapi.json for consistency. * README.md: Add a second ApiError example with next omitted (null), for an endpoint with no related endpoint to suggest. Note that spec_url is always /openapi.json on every error from every endpoint, and that / and /version document the 500 response without currently having a way to produce one. --- src/lib.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib.rs b/src/lib.rs index aecdf36..37dd70c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -44,7 +44,8 @@ fn request_id_string(request_id: &RequestId) -> Option { } #[utoipa::path(get, path = "/", responses( - (status = 200, description = "Greeting", body = String) + (status = 200, description = "Greeting", body = String), + (status = 500, description = "Internal error", body = ApiError) ))] async fn hello_world() -> &'static str { "Hello, world!" @@ -61,7 +62,8 @@ struct VersionInfo { } #[utoipa::path(get, path = "/version", responses( - (status = 200, description = "Build information", body = VersionInfo) + (status = 200, description = "Build information", body = VersionInfo), + (status = 500, description = "Internal error", body = ApiError) ))] async fn version() -> Json { Json(VersionInfo { -- cgit 1.4.1