pinakes-server: add utoipa annotations to all routes; fix tests
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I28cf5b7b7cff8e90e123d624d97cf9656a6a6964
This commit is contained in:
parent
8bde7f8fc2
commit
625077f341
60 changed files with 3493 additions and 242 deletions
|
|
@ -14,6 +14,18 @@ use crate::{
|
|||
state::AppState,
|
||||
};
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/config",
|
||||
tag = "config",
|
||||
responses(
|
||||
(status = 200, description = "Current server configuration", body = ConfigResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn get_config(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<ConfigResponse>, ApiError> {
|
||||
|
|
@ -63,6 +75,17 @@ pub async fn get_config(
|
|||
}))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/config/ui",
|
||||
tag = "config",
|
||||
responses(
|
||||
(status = 200, description = "UI configuration", body = UiConfigResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn get_ui_config(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<UiConfigResponse>, ApiError> {
|
||||
|
|
@ -70,6 +93,19 @@ pub async fn get_ui_config(
|
|||
Ok(Json(UiConfigResponse::from(&config.ui)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
patch,
|
||||
path = "/api/v1/config/ui",
|
||||
tag = "config",
|
||||
request_body = UpdateUiConfigRequest,
|
||||
responses(
|
||||
(status = 200, description = "Updated UI configuration", body = UiConfigResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn update_ui_config(
|
||||
State(state): State<AppState>,
|
||||
Json(req): Json<UpdateUiConfigRequest>,
|
||||
|
|
@ -104,6 +140,19 @@ pub async fn update_ui_config(
|
|||
Ok(Json(UiConfigResponse::from(&config.ui)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
patch,
|
||||
path = "/api/v1/config/scanning",
|
||||
tag = "config",
|
||||
request_body = UpdateScanningRequest,
|
||||
responses(
|
||||
(status = 200, description = "Updated configuration", body = ConfigResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn update_scanning_config(
|
||||
State(state): State<AppState>,
|
||||
Json(req): Json<UpdateScanningRequest>,
|
||||
|
|
@ -169,6 +218,20 @@ pub async fn update_scanning_config(
|
|||
}))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/config/roots",
|
||||
tag = "config",
|
||||
request_body = RootDirRequest,
|
||||
responses(
|
||||
(status = 200, description = "Updated configuration", body = ConfigResponse),
|
||||
(status = 400, description = "Bad request"),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn add_root(
|
||||
State(state): State<AppState>,
|
||||
Json(req): Json<RootDirRequest>,
|
||||
|
|
@ -196,6 +259,19 @@ pub async fn add_root(
|
|||
get_config(State(state)).await
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/api/v1/config/roots",
|
||||
tag = "config",
|
||||
request_body = RootDirRequest,
|
||||
responses(
|
||||
(status = 200, description = "Updated configuration", body = ConfigResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 403, description = "Forbidden"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
security(("bearer_auth" = []))
|
||||
)]
|
||||
pub async fn remove_root(
|
||||
State(state): State<AppState>,
|
||||
Json(req): Json<RootDirRequest>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue