feat: add utoipa path annotations to hackathon and QR handlers, register in swagger
All hackathon endpoints (/v1/hackathon/*) and QR endpoints (/v1/qr/*) are now visible in the Swagger UI at /docs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
8144ab40e9
commit
e1bc336baa
@@ -15,6 +15,18 @@ use crate::qr::{
|
||||
middleware::qr_auth::QrAuthUser,
|
||||
};
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/v1/qr/campaigns",
|
||||
request_body = CreateCampaignRequest,
|
||||
responses(
|
||||
(status = 201, description = "Create a QR campaign"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
tag = "QR - Campaigns",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn create_campaign_handler(
|
||||
Extension(service): Extension<Arc<dyn QrCampaignService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
@@ -31,6 +43,17 @@ pub async fn create_campaign_handler(
|
||||
Ok(imphnen_utils::response_format::ApiCreated(campaign).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/v1/qr/campaigns",
|
||||
responses(
|
||||
(status = 200, description = "Admin: list all QR campaigns"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
tag = "QR - Campaigns",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn list_campaigns_handler(
|
||||
Extension(service): Extension<Arc<dyn QrCampaignService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
@@ -44,6 +67,18 @@ pub async fn list_campaigns_handler(
|
||||
Ok(ApiSuccess(campaigns).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
put,
|
||||
path = "/v1/qr/campaigns/{id}/activate",
|
||||
params(("id" = Uuid, Path, description = "Campaign ID")),
|
||||
responses(
|
||||
(status = 200, description = "Admin: activate a campaign"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
tag = "QR - Campaigns",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn activate_campaign_handler(
|
||||
Extension(service): Extension<Arc<dyn QrCampaignService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
@@ -58,6 +93,18 @@ pub async fn activate_campaign_handler(
|
||||
Ok(ApiSuccess(campaign).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/v1/qr/campaigns/{id}",
|
||||
params(("id" = Uuid, Path, description = "Campaign ID")),
|
||||
responses(
|
||||
(status = 200, description = "Admin: delete a campaign"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
tag = "QR - Campaigns",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn delete_campaign_handler(
|
||||
Extension(service): Extension<Arc<dyn QrCampaignService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
@@ -75,6 +122,16 @@ pub async fn delete_campaign_handler(
|
||||
)
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/v1/qr/campaigns/process-image",
|
||||
responses(
|
||||
(status = 200, description = "Process QR code image (multipart/form-data with 'file' field)"),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "QR - Campaigns",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn process_image_handler(
|
||||
Extension(service): Extension<Arc<dyn QrCampaignService>>,
|
||||
Extension(_auth_user): Extension<QrAuthUser>,
|
||||
|
||||
@@ -15,6 +15,16 @@ use crate::qr::{
|
||||
},
|
||||
};
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/v1/qr/users/me",
|
||||
responses(
|
||||
(status = 200, description = "Get my QR user profile"),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "QR - Users",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn get_me_handler(
|
||||
Extension(service): Extension<Arc<dyn QrUserService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
@@ -23,6 +33,17 @@ pub async fn get_me_handler(
|
||||
Ok(ApiSuccess(user).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
put,
|
||||
path = "/v1/qr/users/me",
|
||||
request_body = UpdateProfileRequest,
|
||||
responses(
|
||||
(status = 200, description = "Update my QR user profile"),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "QR - Users",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn update_me_handler(
|
||||
Extension(service): Extension<Arc<dyn QrUserService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
@@ -36,6 +57,17 @@ pub async fn update_me_handler(
|
||||
Ok(ApiSuccess(user).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/v1/qr/users",
|
||||
responses(
|
||||
(status = 200, description = "Admin: list all QR users"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
tag = "QR - Users",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn list_users_handler(
|
||||
Extension(service): Extension<Arc<dyn QrUserService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
@@ -49,6 +81,19 @@ pub async fn list_users_handler(
|
||||
Ok(ApiSuccess(users).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
put,
|
||||
path = "/v1/qr/users/{id}/role",
|
||||
params(("id" = Uuid, Path, description = "User ID")),
|
||||
request_body = UpdateRoleRequest,
|
||||
responses(
|
||||
(status = 200, description = "Admin: update user role"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
tag = "QR - Users",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn update_role_handler(
|
||||
Extension(service): Extension<Arc<dyn QrUserService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
@@ -64,6 +109,18 @@ pub async fn update_role_handler(
|
||||
Ok(ApiSuccess(user).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/v1/qr/users/{id}",
|
||||
params(("id" = Uuid, Path, description = "User ID")),
|
||||
responses(
|
||||
(status = 200, description = "Admin: delete QR user"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden - admin only")
|
||||
),
|
||||
tag = "QR - Users",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn delete_user_handler(
|
||||
Extension(service): Extension<Arc<dyn QrUserService>>,
|
||||
Extension(auth_user): Extension<QrAuthUser>,
|
||||
|
||||
Reference in New Issue
Block a user