apidoc_core/
document.rs

1use std::collections::HashMap;
2
3use serde::{Deserialize, Serialize};
4
5use crate::{error::ApiErrorItem, operation::ApiOperation};
6
7use super::ty::ApiModel;
8
9#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
10pub struct ApiDocument {
11    // 服务标识
12    pub ident: String,
13
14    // 服务名称
15    pub name: String,
16
17    // 服务说明
18    pub note: Option<String>,
19
20    // 服务版本
21    pub version: Option<String>,
22
23    // 模块 id -> module
24    pub modules: HashMap<String, ApiModule>,
25
26    // 资源
27    pub resources: Vec<ApiResource>,
28
29    // 接口
30    pub operations: Vec<ApiOperation>,
31
32    // 实体集合 id -> model
33    pub models: HashMap<String, ApiModel>,
34
35    // 错误
36    pub errors: Vec<ApiErrorItem>,
37}
38
39#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
40pub struct ApiModule {
41    pub ident: String,
42    pub name: String,
43    pub parent: Option<String>,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
47pub struct ApiResource {
48    // 标识符
49    pub ident: String,
50
51    // 值
52    pub value: String,
53}