-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocs.rs
More file actions
80 lines (72 loc) · 2.52 KB
/
Copy pathdocs.rs
File metadata and controls
80 lines (72 loc) · 2.52 KB
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
use utoipa::{
Modify, OpenApi,
openapi::security::SecurityScheme,
};
use super::routes;
#[derive(OpenApi)]
#[openapi(
paths(
// /user
routes::user::register::register,
routes::user::register::verify_account,
routes::user::data::get_user_data,
routes::user::data::update_user_data,
routes::user::change_email::change_email,
routes::user::change_email::verify_email_change,
routes::user::delete::delete,
// /auth
routes::auth::local::login,
routes::auth::oauth::oauth_login_ui,
routes::auth::oauth::google_login,
routes::auth::oauth::github_login,
routes::auth::refresh::refresh_session,
routes::auth::logout::logout,
),
components(
schemas(
// ==== Requests & Responses ====
// /user
routes::user::dtos::RegisterRequest,
routes::user::dtos::RegisterResponse,
routes::user::dtos::VerifyAccountRequest,
routes::user::dtos::VerifyAccountResponse,
routes::user::dtos::ChangeEmailRequest,
routes::user::dtos::ChangeEmailResponse,
routes::user::dtos::VerifyEmailChangeRequest,
routes::user::dtos::VerifyEmailChangeResponse,
routes::user::dtos::UserDataResponse,
routes::user::dtos::UserDataUpdateRequest,
routes::user::dtos::UserDataUpdateResponse,
routes::user::dtos::UserDeletionResponse,
// /auth
routes::auth::dtos::LoginRequest,
routes::auth::dtos::LoginResponse,
routes::auth::dtos::LogoutResponse,
routes::auth::dtos::OAuthLoginRequest,
)
),
modifiers(&SecurityAddon),
)]
pub struct Docs;
pub struct SecurityAddon;
impl Modify for SecurityAddon {
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
let components = openapi.components.get_or_insert_with(Default::default);
components.add_security_scheme(
"cookie_auth",
SecurityScheme::ApiKey(
utoipa::openapi::security::ApiKey::Cookie(
utoipa::openapi::security::ApiKeyValue::new("access_token"),
),
),
);
components.add_security_scheme(
"refresh_cookie_auth",
SecurityScheme::ApiKey(
utoipa::openapi::security::ApiKey::Cookie(
utoipa::openapi::security::ApiKeyValue::new("refresh_token"),
),
),
);
}
}