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
67b8322705
commit
9d58927cb4
60 changed files with 3493 additions and 242 deletions
|
|
@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use super::media::MediaResponse;
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, utoipa::ToSchema)]
|
||||
pub struct RegisterDeviceRequest {
|
||||
pub name: String,
|
||||
pub device_type: String,
|
||||
|
|
@ -11,7 +11,7 @@ pub struct RegisterDeviceRequest {
|
|||
pub os_info: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct DeviceResponse {
|
||||
pub id: String,
|
||||
pub name: String,
|
||||
|
|
@ -42,25 +42,25 @@ impl From<pinakes_core::sync::SyncDevice> for DeviceResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct DeviceRegistrationResponse {
|
||||
pub device: DeviceResponse,
|
||||
pub device_token: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, utoipa::ToSchema)]
|
||||
pub struct UpdateDeviceRequest {
|
||||
pub name: Option<String>,
|
||||
pub enabled: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, utoipa::ToSchema)]
|
||||
pub struct GetChangesParams {
|
||||
pub cursor: Option<i64>,
|
||||
pub limit: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct SyncChangeResponse {
|
||||
pub id: String,
|
||||
pub sequence: i64,
|
||||
|
|
@ -87,14 +87,14 @@ impl From<pinakes_core::sync::SyncLogEntry> for SyncChangeResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct ChangesResponse {
|
||||
pub changes: Vec<SyncChangeResponse>,
|
||||
pub cursor: i64,
|
||||
pub has_more: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, utoipa::ToSchema)]
|
||||
pub struct ClientChangeReport {
|
||||
pub path: String,
|
||||
pub change_type: String,
|
||||
|
|
@ -103,19 +103,19 @@ pub struct ClientChangeReport {
|
|||
pub local_mtime: Option<i64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, utoipa::ToSchema)]
|
||||
pub struct ReportChangesRequest {
|
||||
pub changes: Vec<ClientChangeReport>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct ReportChangesResponse {
|
||||
pub accepted: Vec<String>,
|
||||
pub conflicts: Vec<ConflictResponse>,
|
||||
pub upload_required: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct ConflictResponse {
|
||||
pub id: String,
|
||||
pub path: String,
|
||||
|
|
@ -136,12 +136,12 @@ impl From<pinakes_core::sync::SyncConflict> for ConflictResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, utoipa::ToSchema)]
|
||||
pub struct ResolveConflictRequest {
|
||||
pub resolution: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, utoipa::ToSchema)]
|
||||
pub struct CreateUploadSessionRequest {
|
||||
pub target_path: String,
|
||||
pub expected_hash: String,
|
||||
|
|
@ -149,7 +149,7 @@ pub struct CreateUploadSessionRequest {
|
|||
pub chunk_size: Option<u64>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct UploadSessionResponse {
|
||||
pub id: String,
|
||||
pub target_path: String,
|
||||
|
|
@ -178,19 +178,19 @@ impl From<pinakes_core::sync::UploadSession> for UploadSessionResponse {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct ChunkUploadedResponse {
|
||||
pub chunk_index: u64,
|
||||
pub received: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
#[derive(Debug, Deserialize, utoipa::ToSchema)]
|
||||
pub struct AcknowledgeChangesRequest {
|
||||
pub cursor: i64,
|
||||
}
|
||||
|
||||
// Most viewed (uses MediaResponse)
|
||||
#[derive(Debug, Serialize)]
|
||||
#[derive(Debug, Serialize, utoipa::ToSchema)]
|
||||
pub struct MostViewedResponse {
|
||||
pub media: MediaResponse,
|
||||
pub view_count: u64,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue