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
|
use utoipa::{
Modify, OpenApi,
openapi::security::{HttpAuthScheme, HttpBuilder, SecurityScheme},
};
use crate::ErrorResponse;
pub mod tags {
pub const ACCOUNT: &str = "Account";
pub const QUEUE: &str = "Queue";
}
struct AuthModifier;
impl Modify for AuthModifier {
fn modify(&self, openapi: &mut utoipa::openapi::OpenApi) {
if let Some(components) = openapi.components.as_mut() {
components.add_security_scheme(
"auth",
SecurityScheme::Http(
HttpBuilder::new()
.scheme(HttpAuthScheme::Bearer)
.bearer_format("JWT")
.build(),
),
)
}
}
}
#[derive(OpenApi)]
#[openapi(
info(
title = "ITMO queue server API",
description = "Queue service",
license(
name = "AGPL-3.0",
url="https://www.gnu.org/licenses/agpl-3.0.en.html#license-text"
),
),
servers(
(
url = "http://{host}:{port}/",
description = "Local server",
variables(
("host" = (default = "localhost", description="Server host")),
("port" = (default = "8888", description="Server port"))
)
),
(url = "https://очередь.псж.онлайн/api/v1/", description = "Production server"),
),
tags(
(name=tags::ACCOUNT, description="Account management methods")
),
components(
schemas(ErrorResponse)
),
modifiers(&AuthModifier)
)]
pub struct AppOpenApi;
|