diff options
Diffstat (limited to 'server/src/api_model.rs')
| -rw-r--r-- | server/src/api_model.rs | 48 |
1 files changed, 43 insertions, 5 deletions
diff --git a/server/src/api_model.rs b/server/src/api_model.rs index a7c8e88..f3bb5cf 100644 --- a/server/src/api_model.rs +++ b/server/src/api_model.rs @@ -1,7 +1,7 @@ -use rocket::serde::Serialize; +use rocket::serde::{Deserialize, Serialize}; use utoipa::ToSchema; -#[derive(Serialize, Copy, Clone, ToSchema)] +#[derive(Deserialize, Serialize, Copy, Clone, ToSchema)] pub enum ReviewState { Draft, Open, @@ -9,6 +9,13 @@ pub enum ReviewState { Closed, } +#[derive(Deserialize, Serialize, Copy, Clone, ToSchema)] +pub enum UserReviewRole { + Reviewer, + Watcher, + None, +} + #[derive(Serialize, ToSchema)] pub struct User { #[schema(example = 1337u64)] @@ -22,6 +29,13 @@ pub struct User { } #[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, @@ -30,8 +44,7 @@ pub struct Review { #[schema(example = "We're adding more features because features are what we want.")] pub description: String, pub owner: User, - pub reviewers: Vec<User>, - pub watchers: Vec<User>, + pub users: Vec<ReviewUserEntry>, #[schema(example = ReviewState::Open)] pub state: ReviewState, #[schema(example = 37.5)] @@ -65,6 +78,23 @@ pub struct Reviews { } #[derive(Serialize, ToSchema)] +pub struct ProjectUserEntry { + pub user: User, + #[schema(example = UserReviewRole::Reviewer)] + pub default_role: UserReviewRole, + #[schema(example = false)] + pub maintainer: bool, +} + +#[derive(Deserialize, ToSchema)] +pub struct ProjectUserEntryData { + #[schema(example = UserReviewRole::Reviewer)] + pub default_role: Option<UserReviewRole>, + #[schema(example = false)] + pub maintainer: Option<bool>, +} + +#[derive(Serialize, ToSchema)] pub struct Project { #[schema(example = 1u64)] pub id: u64, @@ -72,7 +102,15 @@ pub struct Project { pub title: String, #[schema(example = "Example project")] pub description: String, - pub members: Vec<User>, + pub users: Vec<ProjectUserEntry>, +} + +#[derive(Deserialize, 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(Serialize, ToSchema)] |
