Skip to content

Commit 21b6e6b

Browse files
committed
utoipa: Add annotations to /site_metadata endpoints
1 parent 14ccd6a commit 21b6e6b

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

src/controllers/site_metadata.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@ use crate::app::AppState;
22
use axum::response::IntoResponse;
33
use axum_extra::json;
44

5-
/// Returns the JSON representation of the current deployed commit sha.
5+
/// Get crates.io metadata.
66
///
7-
/// The sha is contained within the `HEROKU_SLUG_COMMIT` environment variable.
8-
/// If `HEROKU_SLUG_COMMIT` is not set, returns `"unknown"`.
7+
/// Returns the current deployed commit SHA1 (or `unknown`), and whether the
8+
/// system is in read-only mode.
9+
#[utoipa::path(
10+
get,
11+
path = "/api/v1/site_metadata",
12+
operation_id = "get_site_metadata",
13+
tag = "other",
14+
responses((status = 200, description = "Successful Response")),
15+
)]
916
pub async fn show_deployed_sha(state: AppState) -> impl IntoResponse {
1017
let read_only = state.config.db.are_all_read_only();
1118

src/router.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,10 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
5959
.routes(routes!(summary::summary))
6060
.routes(routes!(user::me::confirm_user_email))
6161
.routes(routes!(user::resend::regenerate_token_and_send))
62+
.routes(routes!(site_metadata::show_deployed_sha))
6263
.split_for_parts();
6364

6465
let mut router = router
65-
.route(
66-
"/api/v1/site_metadata",
67-
get(site_metadata::show_deployed_sha),
68-
)
6966
// Session management
7067
.route("/api/private/session/begin", get(user::session::begin))
7168
.route(

src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,21 @@ snapshot_kind: text
592592
]
593593
}
594594
},
595+
"/api/v1/site_metadata": {
596+
"get": {
597+
"description": "Returns the current deployed commit SHA1 (or `unknown`), and whether the\nsystem is in read-only mode.",
598+
"operationId": "get_site_metadata",
599+
"responses": {
600+
"200": {
601+
"description": "Successful Response"
602+
}
603+
},
604+
"summary": "Get crates.io metadata.",
605+
"tags": [
606+
"other"
607+
]
608+
}
609+
},
595610
"/api/v1/summary": {
596611
"get": {
597612
"description": "This endpoint returns a summary of the most important data for the front\npage of crates.io.",

0 commit comments

Comments
 (0)