aboutsummaryrefslogtreecommitdiff
path: root/src/response/mod.rs
blob: d555596a886aaa510193c8eefabe15767cb97ee4 (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
mod error;
mod success;

pub use error::ErrorResponse;
pub use success::SuccessResponse;

use utoipa::IntoResponses;

pub type ApiResult<T> = Result<SuccessResponse<T>, ErrorResponse>;

#[derive(IntoResponses)]
pub enum GlobalResponses {
    #[response(
        status = 400,
        description = "General response for invalid request",
        examples(
            ("Fail" = (value = json!(ErrorResponse::fail("SomeFailKind", "some fail message"))))
        )
    )]
    Fail(ErrorResponse),
    #[response(
        status = 500,
        description = "General response when a server error occurs",
        examples(
            ("Error" = (value = json!(ErrorResponse::error("SomeErrorKind", "some error message"))))
        )
    )]
    Error(ErrorResponse),
}