summaryrefslogtreecommitdiff
path: root/server/src/api_model.rs
blob: a7c8e88c7fe521fab8256504d5606a943642109b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
use rocket::serde::Serialize;
use utoipa::ToSchema;

#[derive(Serialize, Copy, Clone, ToSchema)]
pub enum ReviewState {
    Draft,
    Open,
    Dropped,
    Closed,
}

#[derive(Serialize, 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(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 reviewers: Vec<User>,
    pub watchers: Vec<User>,
    #[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<ReviewEntry>,
}

#[derive(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 members: Vec<User>,
}

#[derive(Serialize, ToSchema)]
pub struct ProjectEntry {
    #[schema(example = 1u64)]
    pub id: u64,
    #[schema(example = "FAKE: Features All Kids Erase")]
    pub title: String,
}

#[derive(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<ProjectEntry>,
}

#[derive(Serialize, ToSchema)]
pub struct StatusResponse {
    pub ok: bool,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub error: Option<&'static str>,
}