use rocket::serde::{Deserialize, Serialize}; use utoipa::ToSchema; #[derive(Copy, Clone, Deserialize, Serialize, ToSchema)] pub enum ReviewState { Draft, Open, Dropped, Closed, } #[derive(Copy, Clone, Debug, Deserialize, PartialEq, Serialize, ToSchema)] pub enum UserReviewRole { Reviewer, Watcher, None, } #[derive(Debug, Deserialize, Serialize, PartialEq, ToSchema)] pub struct User { #[schema(example = 1337u64)] pub id: u64, #[schema(example = "jsmith")] pub username: String, #[schema(example = "John Smith")] pub name: String, #[schema(example = true)] pub active: bool, } #[derive(Deserialize, Serialize, ToSchema)] pub struct Users { #[schema(example = 0u32)] pub offset: u32, #[schema(example = 10u32)] pub limit: u32, #[schema(example = 42u32)] pub total_count: u32, #[schema(example = true)] pub more: bool, pub users: Vec, } #[derive(Serialize, ToSchema)] pub struct ReviewUserEntry { pub user: User, #[schema(example = UserReviewRole::Reviewer)] pub role: UserReviewRole, } #[derive(Serialize, ToSchema)] pub struct Review { #[schema(example = 1000u64)] pub id: u64, #[schema(example = "FAKE-512: Add more features")] pub title: String, #[schema(example = "We're adding more features because features are what we want.")] pub description: String, pub owner: User, pub users: Vec, #[schema(example = ReviewState::Open)] pub state: ReviewState, #[schema(example = 37.5)] pub progress: f32, } #[derive(Serialize, ToSchema)] pub struct ReviewEntry { #[schema(example = 1000u64)] pub id: u64, #[schema(example = "FAKE-512: Add more features")] pub title: String, pub owner: User, #[schema(example = ReviewState::Open)] pub state: ReviewState, #[schema(example = 37.5)] pub progress: f32, } #[derive(Serialize, ToSchema)] pub struct Reviews { #[schema(example = 0u32)] pub offset: u32, #[schema(example = 10u32)] pub limit: u32, #[schema(example = 42u32)] pub total_count: u32, #[schema(example = true)] pub more: bool, pub reviews: Vec, } #[derive(Debug, Deserialize, PartialEq, Serialize, ToSchema)] pub struct ProjectUserEntry { pub user: User, #[schema(example = UserReviewRole::Reviewer)] pub default_role: UserReviewRole, #[schema(example = false)] pub maintainer: bool, } #[derive(Deserialize, Serialize, ToSchema)] pub struct ProjectUserEntryData { #[schema(example = UserReviewRole::Reviewer)] pub default_role: Option, #[schema(example = false)] pub maintainer: Option, } #[derive(Debug, Deserialize, PartialEq, Serialize, ToSchema)] pub struct Project { #[schema(example = 1u64)] pub id: u64, #[schema(example = "FAKE: Features All Kids Erase")] pub title: String, #[schema(example = "Example project")] pub description: String, pub users: Vec, } #[derive(Deserialize, Serialize, ToSchema)] pub struct ProjectData<'r> { #[schema(example = "FAKE: Features All Kids Erase")] pub title: Option<&'r str>, #[schema(example = "Example project")] pub description: Option<&'r str>, } #[derive(Deserialize, Serialize, ToSchema)] pub struct ProjectEntry { #[schema(example = 1u64)] pub id: u64, #[schema(example = "FAKE: Features All Kids Erase")] pub title: String, } #[derive(Deserialize, Serialize, ToSchema)] pub struct Projects { #[schema(example = 0u32)] pub offset: u32, #[schema(example = 10u32)] pub limit: u32, #[schema(example = 1u32)] pub total_count: u32, #[schema(example = false)] pub more: bool, pub projects: Vec, } #[derive(Deserialize, Serialize, ToSchema)] pub struct StatusResponse { pub ok: bool, #[serde( skip_serializing_if = "Option::is_none", // &'static str is problematic for serde, only used in tests anyway. skip_deserializing, )] pub error: Option<&'static str>, }