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
|
use utoipa::{
openapi::security::{HttpAuthScheme, HttpBuilder, SecurityScheme},
Modify, OpenApi,
};
use crate::auth;
use crate::api;
pub fn get_openapi() -> utoipa::openapi::OpenApi {
/* utoipa setup */
#[derive(OpenApi)]
#[openapi(
paths(
api::album::post_album,
api::album::put_album,
api::album::get_album,
api::album::delete_album,
api::artist::post_artist,
api::artist::put_artist,
api::artist::get_artist,
api::artist::delete_artist,
api::song::post_song,
api::song::put_song,
api::song::get_song,
api::song::delete_song,
api::search_results::search_results,
auth::register,
auth::login,
auth::delete_user,
),
components(
schemas(
)
),
modifiers(&SecurityAddon)
)]
struct ApiDoc;
struct SecurityAddon;
impl Modify for SecurityAddon {
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
let components = openapi.components.as_mut().unwrap();
components.add_security_scheme(
"bearer_auth",
SecurityScheme::Http(
HttpBuilder::new()
.scheme(HttpAuthScheme::Bearer)
.bearer_format("JWT")
.build(),
),
);
}
}
return ApiDoc::openapi();
}
|