-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathapi_doc.rs
More file actions
71 lines (65 loc) · 1.94 KB
/
Copy pathapi_doc.rs
File metadata and controls
71 lines (65 loc) · 1.94 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
use stackable_cockpit::{
common::manifest::ManifestSpec,
platform::{
cluster::ResourceRequests, demo, product::ProductSpec, release, stacklet::Stacklet,
},
utils::{k8s::DisplayCondition, params::Parameter},
};
use utoipa::{
OpenApi,
openapi::security::{HttpAuthScheme, SecurityScheme},
};
use crate::{
handlers,
middleware::{
self,
authentication::{Session, SessionToken},
},
};
#[derive(Debug, OpenApi)]
#[openapi(
info(description = "stackable-cockpitd API specification"),
servers((url = "/api")),
paths(
handlers::root::ping,
handlers::demos::get_demos,
handlers::demos::get_demo,
handlers::releases::get_releases,
handlers::releases::get_release,
handlers::stacklets::get_stacklets,
middleware::authentication::log_in,
),
components(schemas(
demo::DemoSpec, ManifestSpec, Parameter, release::ReleaseSpec,
Stacklet, DisplayCondition, synthetic_types::ObjectMeta,
Session, SessionToken, ResourceRequests, ProductSpec
))
)]
struct ApiDoc {}
pub fn openapi() -> utoipa::openapi::OpenApi {
let mut docs = ApiDoc::openapi();
docs.components
.get_or_insert_with(Default::default)
.add_security_schemes_from_iter([
(
"session_token",
SecurityScheme::Http(utoipa::openapi::security::Http::new(HttpAuthScheme::Bearer)),
),
(
"basic",
SecurityScheme::Http(utoipa::openapi::security::Http::new(HttpAuthScheme::Basic)),
),
]);
docs
}
/// Synthetic types that are used to generate type definitions for foreign types.
/// These are unused in this crate, so we explicitly allow the dead code.
#[allow(dead_code)]
mod synthetic_types {
use utoipa::ToSchema;
#[derive(ToSchema)]
pub struct ObjectMeta {
pub name: String,
pub namespace: String,
}
}