feat: added openapi doc
All checks were successful
Test / lint-frontend (pull_request) Successful in 45s
Test / test-frontend (pull_request) Successful in 44s
Test / frontend-build (pull_request) Successful in 47s
Verify / verify-generated-agent-code (pull_request) Successful in 1m15s
Verify / verify-openapi-spec (pull_request) Successful in 2m29s
Verify / verify-generated-database-code (pull_request) Successful in 2m35s
Verify / verify-frontend-api-client (pull_request) Successful in 19s
Test / lint-crates (pull_request) Successful in 59s
Test / test-crates (pull_request) Successful in 2m44s
All checks were successful
Test / lint-frontend (pull_request) Successful in 45s
Test / test-frontend (pull_request) Successful in 44s
Test / frontend-build (pull_request) Successful in 47s
Verify / verify-generated-agent-code (pull_request) Successful in 1m15s
Verify / verify-openapi-spec (pull_request) Successful in 2m29s
Verify / verify-generated-database-code (pull_request) Successful in 2m35s
Verify / verify-frontend-api-client (pull_request) Successful in 19s
Test / lint-crates (pull_request) Successful in 59s
Test / test-crates (pull_request) Successful in 2m44s
This commit is contained in:
@@ -3,6 +3,7 @@ pub mod tag {
|
||||
pub const HEALTH_TAG: &str = "Health";
|
||||
pub const AUTH_TAG: &str = "Authentication";
|
||||
pub const USER_TAG: &str = "User";
|
||||
pub const NGINX_TAG: &str = "Nginx";
|
||||
}
|
||||
|
||||
#[derive(utoipa::OpenApi)]
|
||||
@@ -14,6 +15,16 @@ pub mod tag {
|
||||
crate::routes::api::auth::init_admin::init_admin,
|
||||
// User management paths
|
||||
crate::routes::api::restricted::user::me::get_user_info,
|
||||
// Nginx upstream management
|
||||
crate::routes::api::restricted::nginx::upstream::create_upstream::create_upstream,
|
||||
crate::routes::api::restricted::nginx::upstream::create_upstream_target::add_upstream_target,
|
||||
crate::routes::api::restricted::nginx::upstream::get_upstream::get_upstream_list,
|
||||
crate::routes::api::restricted::nginx::upstream::get_upstream::get_upstream,
|
||||
crate::routes::api::restricted::nginx::upstream::get_upstream_target::get_upstream_target,
|
||||
crate::routes::api::restricted::nginx::upstream::update_upstream::update_upstream,
|
||||
crate::routes::api::restricted::nginx::upstream::update_upstream_target::update_upstream_target,
|
||||
crate::routes::api::restricted::nginx::upstream::remove_upstream::remove_upstream,
|
||||
crate::routes::api::restricted::nginx::upstream::remove_upstream_target::remove_upstream_target,
|
||||
),
|
||||
components(
|
||||
schemas(crate::routes::api::health::info::HealthInfo),
|
||||
@@ -22,11 +33,25 @@ pub mod tag {
|
||||
schemas(crate::routes::api::auth::init_admin::AdminInitRequest),
|
||||
// User management schemas
|
||||
schemas(crate::routes::api::restricted::user::me::UserInfo),
|
||||
// Nginx upstream schemas
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::create_upstream::CreateUpstreamRequestBody),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::create_upstream_target::CreateUpstreamTargetInfo),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::get_upstream::GetUpstreamParams),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::get_upstream_target::GetUpstreamTargetsParams),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::info::response::UpstreamTargetInfo),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::info::response::UpstreamInfoResponse),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::info::response::UpstreamListResponse),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::info::response::UpstreamTargetInfoResponse),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::update_upstream::UpdateUpstreamRequestBody),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::update_upstream_target::UpdateUpstreamTargetRequestBody),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::info::response::UpdateUpstreamInfoResponse),
|
||||
schemas(crate::routes::api::restricted::nginx::upstream::info::response::UpdateUpstreamTargetInfoResponse),
|
||||
),
|
||||
tags(
|
||||
(name = tag::HEALTH_TAG, description = "Health information API"),
|
||||
(name = tag::AUTH_TAG, description = "Authentication API"),
|
||||
(name = tag::USER_TAG, description = "User management API")
|
||||
(name = tag::USER_TAG, description = "User management API"),
|
||||
(name = tag::NGINX_TAG, description = "Nginx management API")
|
||||
)
|
||||
)]
|
||||
pub struct ApiDoc;
|
||||
|
||||
@@ -6,7 +6,13 @@ use sea_orm::TransactionTrait;
|
||||
use crate::{
|
||||
errors::api_error::ApiError,
|
||||
middlewares::request_info::AuthenticatedRequestInfo,
|
||||
routes::{AppState, api::restricted::nginx::upstream::info::response::UpstreamInfoResponse},
|
||||
routes::{
|
||||
AppState,
|
||||
api::{
|
||||
openapi::tag::NGINX_TAG,
|
||||
restricted::nginx::upstream::info::response::UpstreamInfoResponse,
|
||||
},
|
||||
},
|
||||
services::nginx::info::upstream::UpstreamCreateInfo,
|
||||
};
|
||||
|
||||
@@ -75,6 +81,18 @@ impl From<CreateUpstreamRequestBody> for ConcreteCreateUpstreamRequestBody {
|
||||
}
|
||||
|
||||
#[axum::debug_handler]
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/upstreams",
|
||||
request_body = CreateUpstreamRequestBody,
|
||||
responses(
|
||||
(status = 200, description = "Upstream created successfully", body = UpstreamInfoResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 422, description = "Invalid request"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn create_upstream(
|
||||
request_info: AuthenticatedRequestInfo,
|
||||
State(state): State<Arc<AppState>>,
|
||||
|
||||
@@ -7,7 +7,11 @@ use crate::{
|
||||
errors::api_error::ApiError,
|
||||
middlewares::request_info::AuthenticatedRequestInfo,
|
||||
routes::{
|
||||
AppState, api::restricted::nginx::upstream::info::response::UpstreamTargetInfoResponse,
|
||||
AppState,
|
||||
api::{
|
||||
openapi::tag::NGINX_TAG,
|
||||
restricted::nginx::upstream::info::response::UpstreamTargetInfoResponse,
|
||||
},
|
||||
},
|
||||
services::nginx::info::upstream_target::UpstreamTargetCreateInfo,
|
||||
};
|
||||
@@ -45,6 +49,18 @@ impl From<CreateUpstreamTargetInfo> for ConcreteCreateUpstreamTargetInfo {
|
||||
}
|
||||
|
||||
#[axum::debug_handler]
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/upstreams/{upstream_id}/targets",
|
||||
request_body = CreateUpstreamTargetInfo,
|
||||
responses(
|
||||
(status = 200, description = "Upstream target created successfully", body = UpstreamTargetInfoResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 422, description = "Invalid request"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn add_upstream_target(
|
||||
_request_info: AuthenticatedRequestInfo,
|
||||
State(state): State<Arc<AppState>>,
|
||||
|
||||
@@ -14,6 +14,7 @@ use crate::{
|
||||
AppState,
|
||||
api::{
|
||||
helper::pagination::{ExtractPagination, PaginationInfo},
|
||||
openapi::tag::NGINX_TAG,
|
||||
restricted::nginx::upstream::info::response::{
|
||||
UpstreamInfoResponse, UpstreamListResponse,
|
||||
},
|
||||
@@ -39,6 +40,15 @@ impl From<GetUpstreamParams> for ConcreteGetUpstreamParams {
|
||||
}
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/upstreams",
|
||||
responses(
|
||||
(status = 200, description = "List upstreams", body = UpstreamListResponse),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn get_upstream_list(
|
||||
ExtractPagination(pagination): ExtractPagination,
|
||||
State(state): State<Arc<AppState>>,
|
||||
@@ -60,6 +70,16 @@ pub async fn get_upstream_list(
|
||||
}))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/upstreams/{upstream_id}",
|
||||
responses(
|
||||
(status = 200, description = "Get upstream info", body = UpstreamInfoResponse),
|
||||
(status = 404, description = "Not found"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn get_upstream(
|
||||
Path(upstream_id): Path<Uuid>,
|
||||
Query(params): Query<GetUpstreamParams>,
|
||||
|
||||
@@ -10,7 +10,13 @@ use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
errors::api_error::ApiError,
|
||||
routes::{AppState, api::restricted::nginx::upstream::info::response::UpstreamTargetInfo},
|
||||
routes::{
|
||||
AppState,
|
||||
api::{
|
||||
openapi::tag::NGINX_TAG,
|
||||
restricted::nginx::upstream::info::response::UpstreamTargetInfo,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize, utoipa::ToSchema)]
|
||||
@@ -30,6 +36,16 @@ impl From<GetUpstreamTargetsParams> for ConcreteGetUpstreamTargetsParams {
|
||||
}
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/upstream_targets/{upstream_target_id}",
|
||||
responses(
|
||||
(status = 200, description = "Get upstream target info", body = UpstreamTargetInfo),
|
||||
(status = 404, description = "Not found"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn get_upstream_target(
|
||||
Path(upstream_target_id): Path<Uuid>,
|
||||
Query(params): Query<GetUpstreamTargetsParams>,
|
||||
|
||||
@@ -9,10 +9,22 @@ use sea_orm::TransactionTrait;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
errors::api_error::ApiError, middlewares::request_info::AuthenticatedRequestInfo,
|
||||
routes::AppState,
|
||||
errors::api_error::ApiError,
|
||||
middlewares::request_info::AuthenticatedRequestInfo,
|
||||
routes::{AppState, api::openapi::tag::NGINX_TAG},
|
||||
};
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/api/upstreams/{upstream_id}",
|
||||
responses(
|
||||
(status = 200, description = "Upstream removed successfully", body = ()),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 404, description = "Not found"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn remove_upstream(
|
||||
_request_info: AuthenticatedRequestInfo,
|
||||
Path(upstream_id): Path<Uuid>,
|
||||
|
||||
@@ -9,10 +9,22 @@ use sea_orm::TransactionTrait;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
errors::api_error::ApiError, middlewares::request_info::AuthenticatedRequestInfo,
|
||||
routes::AppState,
|
||||
errors::api_error::ApiError,
|
||||
middlewares::request_info::AuthenticatedRequestInfo,
|
||||
routes::{AppState, api::openapi::tag::NGINX_TAG},
|
||||
};
|
||||
|
||||
#[utoipa::path(
|
||||
delete,
|
||||
path = "/api/upstream_targets/{upstream_target_id}",
|
||||
responses(
|
||||
(status = 200, description = "Upstream target removed successfully", body = ()),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 404, description = "Not found"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn remove_upstream_target(
|
||||
_request_info: AuthenticatedRequestInfo,
|
||||
Path(upstream_target_id): Path<Uuid>,
|
||||
|
||||
@@ -13,7 +13,8 @@ use crate::{
|
||||
errors::api_error::ApiError,
|
||||
middlewares::request_info::AuthenticatedRequestInfo,
|
||||
routes::{
|
||||
AppState, api::restricted::nginx::upstream::info::response::UpdateUpstreamInfoResponse,
|
||||
AppState, api::openapi::tag::NGINX_TAG,
|
||||
api::restricted::nginx::upstream::info::response::UpdateUpstreamInfoResponse,
|
||||
},
|
||||
services::nginx::info::upstream::UpdateUpstreamInfo,
|
||||
};
|
||||
@@ -47,6 +48,19 @@ impl From<UpdateUpstreamRequestBody> for UpdateUpstreamInfo {
|
||||
}
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
patch,
|
||||
path = "/api/upstreams/{upstream_id}",
|
||||
request_body = UpdateUpstreamRequestBody,
|
||||
responses(
|
||||
(status = 200, description = "Upstream updated successfully", body = UpdateUpstreamInfoResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 404, description = "Not found"),
|
||||
(status = 422, description = "Invalid request"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn update_upstream(
|
||||
_request_info: AuthenticatedRequestInfo,
|
||||
Path(upstream_id): Path<Uuid>,
|
||||
|
||||
@@ -13,7 +13,7 @@ use crate::{
|
||||
errors::api_error::ApiError,
|
||||
middlewares::request_info::AuthenticatedRequestInfo,
|
||||
routes::{
|
||||
AppState,
|
||||
AppState, api::openapi::tag::NGINX_TAG,
|
||||
api::restricted::nginx::upstream::info::response::UpdateUpstreamTargetInfoResponse,
|
||||
},
|
||||
services::nginx::info::upstream_target::UpdateUpstreamTargetInfo,
|
||||
@@ -40,6 +40,19 @@ impl From<UpdateUpstreamTargetRequestBody> for UpdateUpstreamTargetInfo {
|
||||
}
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
patch,
|
||||
path = "/api/upstream_targets/{upstream_target_id}",
|
||||
request_body = UpdateUpstreamTargetRequestBody,
|
||||
responses(
|
||||
(status = 200, description = "Upstream target updated successfully", body = UpdateUpstreamTargetInfoResponse),
|
||||
(status = 401, description = "Unauthorized"),
|
||||
(status = 404, description = "Not found"),
|
||||
(status = 422, description = "Invalid request"),
|
||||
(status = 500, description = "Internal server error"),
|
||||
),
|
||||
tag = NGINX_TAG,
|
||||
)]
|
||||
pub async fn update_upstream_target(
|
||||
_request_info: AuthenticatedRequestInfo,
|
||||
Path(upstream_target_id): Path<Uuid>,
|
||||
|
||||
Reference in New Issue
Block a user