前端: - fix(app): Isar native 文件直接导入 isar_database_native.dart,消除 5 个条件导出类型错误 - chore(app): build_runner 重新生成 .g.dart 文件 (102 outputs) - fix(app): 移除 secure_token_store_factory 未使用的 kIsWeb import 后端: - refactor(diary): 所有创建端点 POST 返回 201 Created (9 handler, 11 端点) - feat(diary): DiaryApiDoc OpenApi derive — 42 路径 + 32 Schema 汇总到 Swagger - feat(diary): DiaryEvent 枚举添加 event_type/payload/to_domain_event 方法 + 4 测试 测试: 84/84 erp-diary 通过, 509/509 全仓库通过, Flutter analyze 0 error
33 lines
966 B
Rust
33 lines
966 B
Rust
use axum::response::{IntoResponse, Json, Response};
|
|
use utoipa::OpenApi;
|
|
|
|
use crate::{ApiDoc, AuthApiDoc, ConfigApiDoc, MessageApiDoc, WorkflowApiDoc};
|
|
|
|
#[cfg(feature = "diary")]
|
|
use crate::DiaryApiDoc;
|
|
|
|
/// GET /docs/openapi.json
|
|
///
|
|
/// 返回 OpenAPI 3.0 规范 JSON 文档,合并所有模块的路径和 schema。
|
|
/// 仅在 debug 模式下可用,生产构建返回 404。
|
|
pub async fn openapi_spec() -> Response {
|
|
#[cfg(debug_assertions)]
|
|
{
|
|
let mut spec = ApiDoc::openapi();
|
|
spec.merge(AuthApiDoc::openapi());
|
|
spec.merge(ConfigApiDoc::openapi());
|
|
spec.merge(WorkflowApiDoc::openapi());
|
|
spec.merge(MessageApiDoc::openapi());
|
|
|
|
#[cfg(feature = "diary")]
|
|
spec.merge(DiaryApiDoc::openapi());
|
|
|
|
Json(serde_json::to_value(spec).unwrap_or_default()).into_response()
|
|
}
|
|
|
|
#[cfg(not(debug_assertions))]
|
|
{
|
|
(axum::http::StatusCode::NOT_FOUND, "Not Found").into_response()
|
|
}
|
|
}
|