Skip to content

Commit e7f1d79

Browse files
committed
utoipa: Add annotations to /confirm/{email_token} endpoints
1 parent 531d4cb commit e7f1d79

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

src/controllers/user/me.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,14 @@ pub async fn updates(app: AppState, req: Parts) -> AppResult<ErasedJson> {
115115
}))
116116
}
117117

118-
/// Handles the `PUT /confirm/:email_token` route
118+
/// Marks the email belonging to the given token as verified.
119+
#[utoipa::path(
120+
put,
121+
path = "/api/v1/confirm/{email_token}",
122+
operation_id = "confirm_user_email",
123+
tag = "users",
124+
responses((status = 200, description = "Successful Response")),
125+
)]
119126
pub async fn confirm_user_email(state: AppState, Path(token): Path<String>) -> AppResult<Response> {
120127
use diesel::update;
121128

src/router.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,10 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
5757
.routes(routes!(crate_owner_invitation::handle_invite_with_token))
5858
.routes(routes!(user::me::update_email_notifications))
5959
.routes(routes!(summary::summary))
60+
.routes(routes!(user::me::confirm_user_email))
6061
.split_for_parts();
6162

6263
let mut router = router
63-
.route(
64-
"/api/v1/confirm/:email_token",
65-
put(user::me::confirm_user_email),
66-
)
6764
.route(
6865
"/api/v1/users/:user_id/resend",
6966
put(user::regenerate_token_and_send),

src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,20 @@ snapshot_kind: text
6262
]
6363
}
6464
},
65+
"/api/v1/confirm/{email_token}": {
66+
"put": {
67+
"operationId": "confirm_user_email",
68+
"responses": {
69+
"200": {
70+
"description": "Successful Response"
71+
}
72+
},
73+
"summary": "Marks the email belonging to the given token as verified.",
74+
"tags": [
75+
"users"
76+
]
77+
}
78+
},
6579
"/api/v1/crates": {
6680
"get": {
6781
"description": "Called in a variety of scenarios in the front end, including:\n- Alphabetical listing of crates\n- List of crates under a specific owner\n- Listing a user's followed crates",

0 commit comments

Comments
 (0)