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:
@@ -1,14 +1,18 @@
|
||||
use axum::response::Json;
|
||||
use serde_json::Value;
|
||||
use utoipa::openapi::OpenApiBuilder;
|
||||
use utoipa::OpenApi;
|
||||
|
||||
use crate::{ApiDoc, AuthApiDoc, ConfigApiDoc, WorkflowApiDoc, MessageApiDoc};
|
||||
|
||||
/// GET /docs/openapi.json
|
||||
///
|
||||
/// 返回 OpenAPI 3.0 规范 JSON 文档
|
||||
/// 返回 OpenAPI 3.0 规范 JSON 文档,合并所有模块的路径和 schema。
|
||||
pub async fn openapi_spec() -> Json<Value> {
|
||||
let mut info = utoipa::openapi::Info::new("ERP Platform API", env!("CARGO_PKG_VERSION"));
|
||||
info.description = Some("ERP 平台底座 REST API 文档".to_string());
|
||||
let mut spec = ApiDoc::openapi();
|
||||
spec.merge(AuthApiDoc::openapi());
|
||||
spec.merge(ConfigApiDoc::openapi());
|
||||
spec.merge(WorkflowApiDoc::openapi());
|
||||
spec.merge(MessageApiDoc::openapi());
|
||||
|
||||
let spec = OpenApiBuilder::new().info(info).build();
|
||||
Json(serde_json::to_value(spec).unwrap_or_default())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user