Skip to content

Commit e8d710b

Browse files
committed
utoipa: Add annotations to /private/crate_owner_invitations endpoints
1 parent 1826d06 commit e8d710b

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

Diff for: src/controllers/crate_owner_invitation.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use std::collections::{HashMap, HashSet};
2727
#[utoipa::path(
2828
get,
2929
path = "/api/v1/me/crate_owner_invitations",
30-
operation_id = "list_crate_owner_invitations",
30+
operation_id = "list_crate_owner_invitations_for_user",
3131
tag = "owners",
3232
responses((status = 200, description = "Successful Response")),
3333
)]
@@ -68,7 +68,14 @@ pub async fn list(app: AppState, req: Parts) -> AppResult<ErasedJson> {
6868
}))
6969
}
7070

71-
/// Handles the `GET /api/private/crate_owner_invitations` route.
71+
/// List all crate owner invitations for a crate or user.
72+
#[utoipa::path(
73+
get,
74+
path = "/api/private/crate_owner_invitations",
75+
operation_id = "list_crate_owner_invitations",
76+
tag = "owners",
77+
responses((status = 200, description = "Successful Response")),
78+
)]
7279
pub async fn private_list(app: AppState, req: Parts) -> AppResult<Json<PrivateListResponse>> {
7380
let mut conn = app.db_read().await?;
7481
let auth = AuthCheck::only_cookie().check(&req, &mut conn).await?;

Diff for: src/router.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use axum::response::IntoResponse;
2-
use axum::routing::{delete, get, post};
2+
use axum::routing::{get, post};
33
use axum::{Json, Router};
44
use http::{Method, StatusCode};
55
use utoipa_axum::routes;
@@ -53,6 +53,7 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
5353
.routes(routes!(token::show, token::revoke))
5454
.routes(routes!(token::revoke_current))
5555
.routes(routes!(crate_owner_invitation::list))
56+
.routes(routes!(crate_owner_invitation::private_list))
5657
.routes(routes!(crate_owner_invitation::handle_invite))
5758
.routes(routes!(crate_owner_invitation::handle_invite_with_token))
5859
.routes(routes!(user::me::update_email_notifications))
@@ -69,11 +70,6 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
6970
let mut router = router
7071
// Metrics
7172
.route("/api/private/metrics/:kind", get(metrics::prometheus))
72-
// Crate ownership invitations management in the frontend
73-
.route(
74-
"/api/private/crate_owner_invitations",
75-
get(crate_owner_invitation::private_list),
76-
)
7773
// Alerts from GitHub scanning for exposed API tokens
7874
.route(
7975
"/api/github/secret-scanning/verify",

Diff for: src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@ snapshot_kind: text
2020
},
2121
"openapi": "3.1.0",
2222
"paths": {
23+
"/api/private/crate_owner_invitations": {
24+
"get": {
25+
"operationId": "list_crate_owner_invitations",
26+
"responses": {
27+
"200": {
28+
"description": "Successful Response"
29+
}
30+
},
31+
"summary": "List all crate owner invitations for a crate or user.",
32+
"tags": [
33+
"owners"
34+
]
35+
}
36+
},
2337
"/api/private/session": {
2438
"delete": {
2539
"operationId": "end_session",
@@ -514,7 +528,7 @@ snapshot_kind: text
514528
},
515529
"/api/v1/me/crate_owner_invitations": {
516530
"get": {
517-
"operationId": "list_crate_owner_invitations",
531+
"operationId": "list_crate_owner_invitations_for_user",
518532
"responses": {
519533
"200": {
520534
"description": "Successful Response"

0 commit comments

Comments
 (0)