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
use crate::ApiInputConfig;
use serde::{Deserialize, Serialize};

// Serializable ApiInput.
// From and Into are in crud-api-derive/input.rs

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiInputSerde {
  pub ident: String,
  pub data: DataSerde,
  pub no_input_file: bool,
  pub heading: Option<String>,
  pub prefix: Option<String>,
  pub config: Vec<ApiInputConfig>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum DataSerde {
  Enum(Vec<ApiInputVariantSerde>),
  Struct(Vec<ApiInputFieldSerde>),
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiInputFieldSerde {
  pub ident: Option<String>,
  pub ty: String,
  pub long: Option<String>,
  pub short: Option<char>,
  pub no_short: Option<bool>,
  pub heading: Option<String>,
  pub help: Option<String>,
  pub long_help: Option<String>,
  pub possible_values: Option<Vec<String>>,
  pub required: Option<bool>,
  pub num_args: Option<String>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiInputVariantSerde {
  pub ident: String,
  pub fields: Vec<String>,
  pub long: Option<String>,
  pub short: Option<char>,
  pub no_short: bool,
  pub no_long: bool,
  pub heading: Option<String>,
  pub help: Option<String>,
  pub long_help: Option<String>,
}