feat: add utoipa path annotations to all API handlers and wire OpenAPI spec
- Add #[utoipa::path] annotations to all 70+ handler functions across auth, config, workflow, and message modules - Add IntoParams/ToSchema derives to Pagination, PaginatedResponse, ApiResponse in erp-core, and MessageQuery/TemplateQuery in erp-message - Collect all module paths into OpenAPI spec via AuthApiDoc, ConfigApiDoc, WorkflowApiDoc, MessageApiDoc structs in erp-server main.rs - Update openapi_spec handler to merge all module specs - The /docs/openapi.json endpoint now returns complete API documentation with all endpoints, request/response schemas, and security requirements
This commit is contained in:
@@ -12,6 +12,18 @@ use crate::dto::{ProcessInstanceResp, StartInstanceReq};
|
||||
use crate::service::instance_service::InstanceService;
|
||||
use crate::workflow_state::WorkflowState;
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/workflow/instances",
|
||||
request_body = StartInstanceReq,
|
||||
responses(
|
||||
(status = 200, description = "成功", body = ApiResponse<ProcessInstanceResp>),
|
||||
(status = 401, description = "未授权"),
|
||||
(status = 403, description = "权限不足"),
|
||||
),
|
||||
security(("bearer_auth" = [])),
|
||||
tag = "流程实例"
|
||||
)]
|
||||
/// POST /api/v1/workflow/instances
|
||||
pub async fn start_instance<S>(
|
||||
State(state): State<WorkflowState>,
|
||||
@@ -38,6 +50,18 @@ where
|
||||
Ok(Json(ApiResponse::ok(resp)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/workflow/instances",
|
||||
params(Pagination),
|
||||
responses(
|
||||
(status = 200, description = "成功", body = ApiResponse<PaginatedResponse<ProcessInstanceResp>>),
|
||||
(status = 401, description = "未授权"),
|
||||
(status = 403, description = "权限不足"),
|
||||
),
|
||||
security(("bearer_auth" = [])),
|
||||
tag = "流程实例"
|
||||
)]
|
||||
/// GET /api/v1/workflow/instances
|
||||
pub async fn list_instances<S>(
|
||||
State(state): State<WorkflowState>,
|
||||
@@ -65,6 +89,19 @@ where
|
||||
})))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/api/v1/workflow/instances/{id}",
|
||||
params(("id" = Uuid, Path, description = "流程实例ID")),
|
||||
responses(
|
||||
(status = 200, description = "成功", body = ApiResponse<ProcessInstanceResp>),
|
||||
(status = 401, description = "未授权"),
|
||||
(status = 403, description = "权限不足"),
|
||||
(status = 404, description = "流程实例不存在"),
|
||||
),
|
||||
security(("bearer_auth" = [])),
|
||||
tag = "流程实例"
|
||||
)]
|
||||
/// GET /api/v1/workflow/instances/{id}
|
||||
pub async fn get_instance<S>(
|
||||
State(state): State<WorkflowState>,
|
||||
@@ -81,6 +118,19 @@ where
|
||||
Ok(Json(ApiResponse::ok(resp)))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/workflow/instances/{id}/suspend",
|
||||
params(("id" = Uuid, Path, description = "流程实例ID")),
|
||||
responses(
|
||||
(status = 200, description = "成功"),
|
||||
(status = 401, description = "未授权"),
|
||||
(status = 403, description = "权限不足"),
|
||||
(status = 404, description = "流程实例不存在"),
|
||||
),
|
||||
security(("bearer_auth" = [])),
|
||||
tag = "流程实例"
|
||||
)]
|
||||
/// POST /api/v1/workflow/instances/{id}/suspend
|
||||
pub async fn suspend_instance<S>(
|
||||
State(state): State<WorkflowState>,
|
||||
@@ -97,6 +147,19 @@ where
|
||||
Ok(Json(ApiResponse::ok(())))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/workflow/instances/{id}/terminate",
|
||||
params(("id" = Uuid, Path, description = "流程实例ID")),
|
||||
responses(
|
||||
(status = 200, description = "成功"),
|
||||
(status = 401, description = "未授权"),
|
||||
(status = 403, description = "权限不足"),
|
||||
(status = 404, description = "流程实例不存在"),
|
||||
),
|
||||
security(("bearer_auth" = [])),
|
||||
tag = "流程实例"
|
||||
)]
|
||||
/// POST /api/v1/workflow/instances/{id}/terminate
|
||||
pub async fn terminate_instance<S>(
|
||||
State(state): State<WorkflowState>,
|
||||
@@ -113,6 +176,19 @@ where
|
||||
Ok(Json(ApiResponse::ok(())))
|
||||
}
|
||||
|
||||
#[utoipa::path(
|
||||
post,
|
||||
path = "/api/v1/workflow/instances/{id}/resume",
|
||||
params(("id" = Uuid, Path, description = "流程实例ID")),
|
||||
responses(
|
||||
(status = 200, description = "成功"),
|
||||
(status = 401, description = "未授权"),
|
||||
(status = 403, description = "权限不足"),
|
||||
(status = 404, description = "流程实例不存在"),
|
||||
),
|
||||
security(("bearer_auth" = [])),
|
||||
tag = "流程实例"
|
||||
)]
|
||||
/// POST /api/v1/workflow/instances/{id}/resume
|
||||
pub async fn resume_instance<S>(
|
||||
State(state): State<WorkflowState>,
|
||||
|
||||
Reference in New Issue
Block a user