Skip to content

Commit 14ccd6a

Browse files
committed
utoipa: Add annotations to /users/{id}/resend endpoints
1 parent e7f1d79 commit 14ccd6a

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

src/controllers/user.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
pub mod me;
22
pub mod other;
3-
mod resend;
3+
pub mod resend;
44
pub mod session;
55
pub mod update;
66

src/controllers/user/resend.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ use diesel_async::scoped_futures::ScopedFutureExt;
1414
use diesel_async::{AsyncConnection, RunQueryDsl};
1515
use http::request::Parts;
1616

17-
/// Handles `PUT /user/:user_id/resend` route
17+
/// Regenerate and send an email verification token.
18+
#[utoipa::path(
19+
put,
20+
path = "/api/v1/users/{id}/resend",
21+
operation_id = "resend_email_verification",
22+
tag = "users",
23+
responses((status = 200, description = "Successful Response")),
24+
)]
1825
pub async fn regenerate_token_and_send(
1926
state: AppState,
2027
Path(param_user_id): Path<i32>,

src/router.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use axum::response::IntoResponse;
2-
use axum::routing::{delete, get, post, put};
2+
use axum::routing::{delete, get, post};
33
use axum::{Json, Router};
44
use http::{Method, StatusCode};
55
use utoipa_axum::routes;
@@ -58,13 +58,10 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
5858
.routes(routes!(user::me::update_email_notifications))
5959
.routes(routes!(summary::summary))
6060
.routes(routes!(user::me::confirm_user_email))
61+
.routes(routes!(user::resend::regenerate_token_and_send))
6162
.split_for_parts();
6263

6364
let mut router = router
64-
.route(
65-
"/api/v1/users/:user_id/resend",
66-
put(user::regenerate_token_and_send),
67-
)
6865
.route(
6966
"/api/v1/site_metadata",
7067
get(site_metadata::show_deployed_sha),

src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,20 @@ snapshot_kind: text
636636
]
637637
}
638638
},
639+
"/api/v1/users/{id}/resend": {
640+
"put": {
641+
"operationId": "resend_email_verification",
642+
"responses": {
643+
"200": {
644+
"description": "Successful Response"
645+
}
646+
},
647+
"summary": "Regenerate and send an email verification token.",
648+
"tags": [
649+
"users"
650+
]
651+
}
652+
},
639653
"/api/v1/users/{id}/stats": {
640654
"get": {
641655
"description": "This currently only returns the total number of downloads for crates owned\nby the user.",

0 commit comments

Comments
 (0)