pinakes-server: add utoipa annotations to all routes; fix tests
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I28cf5b7b7cff8e90e123d624d97cf9656a6a6964
This commit is contained in:
parent
8bde7f8fc2
commit
625077f341
60 changed files with 3493 additions and 242 deletions
|
|
@ -27,6 +27,20 @@ pub struct ShareLinkQuery {
|
|||
pub password: Option<String>,
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/media/{id}/rate",
|
||||
tag = "social",
|
||||
params(("id" = Uuid, Path, description = "Media item ID")),
|
||||
request_body = CreateRatingRequest,
|
||||
responses(
|
||||
(status = 200, description = "Rating saved", body = RatingResponse),
|
||||
(status = 400, description = "Bad request"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn rate_media(
|
||||
State(state): State<AppState>,
|
||||
Extension(username): Extension<String>,
|
||||
|
|
@ -59,6 +73,18 @@ pub async fn rate_media(
|
|||
Ok(Json(RatingResponse::from(rating)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/media/{id}/ratings",
|
||||
tag = "social",
|
||||
params(("id" = Uuid, Path, description = "Media item ID")),
|
||||
responses(
|
||||
(status = 200, description = "Media ratings", body = Vec<RatingResponse>),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn get_media_ratings(
|
||||
State(state): State<AppState>,
|
||||
Path(id): Path<Uuid>,
|
||||
|
|
@ -69,6 +95,20 @@ pub async fn get_media_ratings(
|
|||
))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/media/{id}/comments",
|
||||
tag = "social",
|
||||
params(("id" = Uuid, Path, description = "Media item ID")),
|
||||
request_body = CreateCommentRequest,
|
||||
responses(
|
||||
(status = 200, description = "Comment added", body = CommentResponse),
|
||||
(status = 400, description = "Bad request"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn add_comment(
|
||||
State(state): State<AppState>,
|
||||
Extension(username): Extension<String>,
|
||||
|
|
@ -91,6 +131,18 @@ pub async fn add_comment(
|
|||
Ok(Json(CommentResponse::from(comment)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/media/{id}/comments",
|
||||
tag = "social",
|
||||
params(("id" = Uuid, Path, description = "Media item ID")),
|
||||
responses(
|
||||
(status = 200, description = "Media comments", body = Vec<CommentResponse>),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn get_media_comments(
|
||||
State(state): State<AppState>,
|
||||
Path(id): Path<Uuid>,
|
||||
|
|
@ -101,6 +153,18 @@ pub async fn get_media_comments(
|
|||
))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/favorites",
|
||||
tag = "social",
|
||||
request_body = FavoriteRequest,
|
||||
responses(
|
||||
(status = 200, description = "Added to favorites"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn add_favorite(
|
||||
State(state): State<AppState>,
|
||||
Extension(username): Extension<String>,
|
||||
|
|
@ -114,6 +178,18 @@ pub async fn add_favorite(
|
|||
Ok(Json(serde_json::json!({"added": true})))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/api/v1/favorites/{media_id}",
|
||||
tag = "social",
|
||||
params(("media_id" = Uuid, Path, description = "Media item ID")),
|
||||
responses(
|
||||
(status = 200, description = "Removed from favorites"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn remove_favorite(
|
||||
State(state): State<AppState>,
|
||||
Extension(username): Extension<String>,
|
||||
|
|
@ -127,6 +203,17 @@ pub async fn remove_favorite(
|
|||
Ok(Json(serde_json::json!({"removed": true})))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/favorites",
|
||||
tag = "social",
|
||||
responses(
|
||||
(status = 200, description = "User favorites", body = Vec<MediaResponse>),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn list_favorites(
|
||||
State(state): State<AppState>,
|
||||
Extension(username): Extension<String>,
|
||||
|
|
@ -145,6 +232,19 @@ pub async fn list_favorites(
|
|||
))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/media/share",
|
||||
tag = "social",
|
||||
request_body = CreateShareLinkRequest,
|
||||
responses(
|
||||
(status = 200, description = "Share link created", body = ShareLinkResponse),
|
||||
(status = 400, description = "Bad request"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn create_share_link(
|
||||
State(state): State<AppState>,
|
||||
Extension(username): Extension<String>,
|
||||
|
|
@ -191,6 +291,20 @@ pub async fn create_share_link(
|
|||
Ok(Json(ShareLinkResponse::from(link)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/shared/media/{token}",
|
||||
tag = "social",
|
||||
params(
|
||||
("token" = String, Path, description = "Share token"),
|
||||
("password" = Option<String>, Query, description = "Share password"),
|
||||
),
|
||||
responses(
|
||||
(status = 200, description = "Shared media", body = MediaResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 404, description = "Not found"),
|
||||
)
|
||||
)]
|
||||
pub async fn access_shared_media(
|
||||
State(state): State<AppState>,
|
||||
Path(token): Path<String>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue