Skip to content

Commit

Permalink
utoipa: Add annotations to /private/crate_owner_invitations endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed Dec 13, 2024
1 parent 1826d06 commit e8d710b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
11 changes: 9 additions & 2 deletions src/controllers/crate_owner_invitation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use std::collections::{HashMap, HashSet};
#[utoipa::path(
get,
path = "/api/v1/me/crate_owner_invitations",
operation_id = "list_crate_owner_invitations",
operation_id = "list_crate_owner_invitations_for_user",
tag = "owners",
responses((status = 200, description = "Successful Response")),
)]
Expand Down Expand Up @@ -68,7 +68,14 @@ pub async fn list(app: AppState, req: Parts) -> AppResult<ErasedJson> {
}))
}

/// Handles the `GET /api/private/crate_owner_invitations` route.
/// List all crate owner invitations for a crate or user.
#[utoipa::path(
get,
path = "/api/private/crate_owner_invitations",
operation_id = "list_crate_owner_invitations",
tag = "owners",
responses((status = 200, description = "Successful Response")),
)]
pub async fn private_list(app: AppState, req: Parts) -> AppResult<Json<PrivateListResponse>> {
let mut conn = app.db_read().await?;
let auth = AuthCheck::only_cookie().check(&req, &mut conn).await?;
Expand Down
8 changes: 2 additions & 6 deletions src/router.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use axum::response::IntoResponse;
use axum::routing::{delete, get, post};
use axum::routing::{get, post};
use axum::{Json, Router};
use http::{Method, StatusCode};
use utoipa_axum::routes;
Expand Down Expand Up @@ -53,6 +53,7 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
.routes(routes!(token::show, token::revoke))
.routes(routes!(token::revoke_current))
.routes(routes!(crate_owner_invitation::list))
.routes(routes!(crate_owner_invitation::private_list))
.routes(routes!(crate_owner_invitation::handle_invite))
.routes(routes!(crate_owner_invitation::handle_invite_with_token))
.routes(routes!(user::me::update_email_notifications))
Expand All @@ -69,11 +70,6 @@ pub fn build_axum_router(state: AppState) -> Router<()> {
let mut router = router
// Metrics
.route("/api/private/metrics/:kind", get(metrics::prometheus))
// Crate ownership invitations management in the frontend
.route(
"/api/private/crate_owner_invitations",
get(crate_owner_invitation::private_list),
)
// Alerts from GitHub scanning for exposed API tokens
.route(
"/api/github/secret-scanning/verify",
Expand Down
16 changes: 15 additions & 1 deletion src/snapshots/crates_io__openapi__tests__openapi_snapshot.snap
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ snapshot_kind: text
},
"openapi": "3.1.0",
"paths": {
"/api/private/crate_owner_invitations": {
"get": {
"operationId": "list_crate_owner_invitations",
"responses": {
"200": {
"description": "Successful Response"
}
},
"summary": "List all crate owner invitations for a crate or user.",
"tags": [
"owners"
]
}
},
"/api/private/session": {
"delete": {
"operationId": "end_session",
Expand Down Expand Up @@ -514,7 +528,7 @@ snapshot_kind: text
},
"/api/v1/me/crate_owner_invitations": {
"get": {
"operationId": "list_crate_owner_invitations",
"operationId": "list_crate_owner_invitations_for_user",
"responses": {
"200": {
"description": "Successful Response"
Expand Down

0 comments on commit e8d710b

Please sign in to comment.