1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use std::collections::HashMap;

use serde::{Deserialize, Serialize};

use crate::{error::ApiErrorItem, operation::ApiOperation};

use super::ty::ApiModel;

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct ApiDocument {
    // 服务标识
    pub ident: String,

    // 服务名称
    pub name: String,

    // 服务说明
    pub note: Option<String>,

    // 服务版本
    pub version: Option<String>,

    // 模块 id -> module
    pub modules: HashMap<String, ApiModule>,

    // 资源
    pub resources: Vec<ApiResource>,

    // 接口
    pub operations: Vec<ApiOperation>,

    // 实体集合 id -> model
    pub models: HashMap<String, ApiModel>,

    // 错误
    pub errors: Vec<ApiErrorItem>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ApiModule {
    pub ident: String,
    pub name: String,
    pub parent: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
pub struct ApiResource {
    // 标识符
    pub ident: String,

    // 值
    pub value: String,
}