Skip to main content

openapi_nexus_go/templating/data/
main_sdk_data.rs

1//! Main SDK data for template rendering
2
3use serde::{Deserialize, Serialize};
4
5use crate::templating::data::CommonFileHeaderData;
6
7/// Sub-client information
8#[derive(Debug, Clone, Serialize, Deserialize)]
9pub struct SubClientInfo {
10    pub name: String,
11    pub type_name: String,
12}
13
14/// SDK option function
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct SdkOption {
17    pub name: String,
18    pub param_type: String,
19    pub description: Option<String>,
20}
21
22/// Main SDK data for template rendering
23#[derive(Debug, Clone, Serialize, Deserialize)]
24pub struct MainSdkData {
25    pub sdk_name: String,
26    pub package_name: String,
27    pub sub_clients: Vec<SubClientInfo>,
28    pub sdk_options: Vec<SdkOption>,
29    pub common_file_header: CommonFileHeaderData,
30}
31
32impl MainSdkData {
33    pub fn new(
34        sdk_name: String,
35        package_name: String,
36        common_file_header: CommonFileHeaderData,
37    ) -> Self {
38        Self {
39            sdk_name,
40            package_name,
41            sub_clients: Vec::new(),
42            sdk_options: Vec::new(),
43            common_file_header,
44        }
45    }
46
47    pub fn with_sub_clients(mut self, sub_clients: Vec<SubClientInfo>) -> Self {
48        self.sub_clients = sub_clients;
49        self
50    }
51
52    pub fn with_sdk_options(mut self, sdk_options: Vec<SdkOption>) -> Self {
53        self.sdk_options = sdk_options;
54        self
55    }
56}