Skip to content

Commit 531d4cb

Browse files
committed
utoipa: Add annotations to /summary endpoints
1 parent b92183c commit 531d4cb

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/controllers/summary.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,17 @@ use diesel_async::{AsyncPgConnection, RunQueryDsl};
1212
use futures_util::FutureExt;
1313
use std::future::Future;
1414

15-
/// Handles the `GET /summary` route.
15+
/// Get front page data.
16+
///
17+
/// This endpoint returns a summary of the most important data for the front
18+
/// page of crates.io.
19+
#[utoipa::path(
20+
get,
21+
path = "/api/v1/summary",
22+
operation_id = "get_summary",
23+
tag = "other",
24+
responses((status = 200, description = "Successful Response")),
25+
)]
1626
pub async fn summary(state: AppState) -> AppResult<ErasedJson> {
1727
let mut conn = state.db_read().await?;
1828

src/router.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
5656
.routes(routes!(crate_owner_invitation::handle_invite))
5757
.routes(routes!(crate_owner_invitation::handle_invite_with_token))
5858
.routes(routes!(user::me::update_email_notifications))
59+
.routes(routes!(summary::summary))
5960
.split_for_parts();
6061

6162
let mut router = router
62-
.route("/api/v1/summary", get(summary::summary))
6363
.route(
6464
"/api/v1/confirm/:email_token",
6565
put(user::me::confirm_user_email),

src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,21 @@ snapshot_kind: text
578578
]
579579
}
580580
},
581+
"/api/v1/summary": {
582+
"get": {
583+
"description": "This endpoint returns a summary of the most important data for the front\npage of crates.io.",
584+
"operationId": "get_summary",
585+
"responses": {
586+
"200": {
587+
"description": "Successful Response"
588+
}
589+
},
590+
"summary": "Get front page data.",
591+
"tags": [
592+
"other"
593+
]
594+
}
595+
},
581596
"/api/v1/teams/{team}": {
582597
"get": {
583598
"operationId": "get_team",

0 commit comments

Comments
 (0)