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
@@ -145,7 +145,7 @@ impl From<UpdateTeamRequest> for UpdateTeamInput {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, ToSchema)]
|
||||
#[derive(Debug, Deserialize, ToSchema, utoipa::IntoParams)]
|
||||
pub struct BrowseTeamsQuery {
|
||||
pub search: Option<String>,
|
||||
pub city: Option<String>,
|
||||
|
||||
@@ -13,6 +13,17 @@ use imphnen_utils::{
|
||||
use std::sync::Arc;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/v1/hackathon/teams",
|
||||
request_body = CreateTeamRequest,
|
||||
responses(
|
||||
(status = 200, description = "Create a new team"),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "Hackathon - Teams",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn create_team_handler(
|
||||
Extension(service): Extension<Arc<dyn TeamService>>,
|
||||
Extension(auth): Extension<HackathonAuthUser>,
|
||||
@@ -22,6 +33,16 @@ pub async fn create_team_handler(
|
||||
Ok(ApiSuccess(TeamResponse::from(team)).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/v1/hackathon/teams/{team_id}",
|
||||
params(("team_id" = Uuid, Path, description = "Team ID")),
|
||||
responses(
|
||||
(status = 200, description = "Get team by ID"),
|
||||
(status = 404, description = "Team not found")
|
||||
),
|
||||
tag = "Hackathon - Teams"
|
||||
)]
|
||||
pub async fn get_team_handler(
|
||||
Extension(service): Extension<Arc<dyn TeamService>>,
|
||||
Path(team_id): Path<Uuid>,
|
||||
@@ -30,6 +51,15 @@ pub async fn get_team_handler(
|
||||
Ok(ApiSuccess(TeamResponse::from(team)).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/v1/hackathon/teams/browse",
|
||||
params(BrowseTeamsQuery),
|
||||
responses(
|
||||
(status = 200, description = "Browse teams with filters")
|
||||
),
|
||||
tag = "Hackathon - Teams"
|
||||
)]
|
||||
pub async fn browse_teams_handler(
|
||||
Extension(service): Extension<Arc<dyn TeamService>>,
|
||||
Query(query): Query<BrowseTeamsQuery>,
|
||||
@@ -46,6 +76,16 @@ pub async fn browse_teams_handler(
|
||||
)
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/v1/hackathon/teams/my",
|
||||
responses(
|
||||
(status = 200, description = "Get my teams"),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "Hackathon - Teams",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn get_my_teams_handler(
|
||||
Extension(service): Extension<Arc<dyn TeamService>>,
|
||||
Extension(auth): Extension<HackathonAuthUser>,
|
||||
@@ -62,6 +102,19 @@ pub async fn get_my_teams_handler(
|
||||
)
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
put,
|
||||
path = "/v1/hackathon/teams/{team_id}",
|
||||
params(("team_id" = Uuid, Path, description = "Team ID")),
|
||||
request_body = UpdateTeamRequest,
|
||||
responses(
|
||||
(status = 200, description = "Update team"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden")
|
||||
),
|
||||
tag = "Hackathon - Teams",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn update_team_handler(
|
||||
Extension(service): Extension<Arc<dyn TeamService>>,
|
||||
Extension(auth): Extension<HackathonAuthUser>,
|
||||
@@ -74,6 +127,18 @@ pub async fn update_team_handler(
|
||||
Ok(ApiSuccess(TeamResponse::from(team)).into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/v1/hackathon/teams/{team_id}",
|
||||
params(("team_id" = Uuid, Path, description = "Team ID")),
|
||||
responses(
|
||||
(status = 200, description = "Delete team"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden")
|
||||
),
|
||||
tag = "Hackathon - Teams",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn delete_team_handler(
|
||||
Extension(service): Extension<Arc<dyn TeamService>>,
|
||||
Extension(auth): Extension<HackathonAuthUser>,
|
||||
@@ -83,6 +148,17 @@ pub async fn delete_team_handler(
|
||||
Ok(ApiMessage::ok("Team deleted successfully").into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/v1/hackathon/teams/{team_id}/leave",
|
||||
params(("team_id" = Uuid, Path, description = "Team ID")),
|
||||
responses(
|
||||
(status = 200, description = "Leave team"),
|
||||
(status = 401, description = "Unauthorized")
|
||||
),
|
||||
tag = "Hackathon - Teams",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn leave_team_handler(
|
||||
Extension(service): Extension<Arc<dyn TeamService>>,
|
||||
Extension(auth): Extension<HackathonAuthUser>,
|
||||
@@ -92,6 +168,21 @@ pub async fn leave_team_handler(
|
||||
Ok(ApiMessage::ok("Left team successfully").into_response())
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/v1/hackathon/teams/{team_id}/members/{member_id}",
|
||||
params(
|
||||
("team_id" = Uuid, Path, description = "Team ID"),
|
||||
("member_id" = Uuid, Path, description = "Member user ID")
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Remove team member"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden")
|
||||
),
|
||||
tag = "Hackathon - Teams",
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn remove_member_handler(
|
||||
Extension(service): Extension<Arc<dyn TeamService>>,
|
||||
Extension(auth): Extension<HackathonAuthUser>,
|
||||
|
||||
Reference in New Issue
Block a user