openapi_nexus_go/
config.rs1use serde::{Deserialize, Serialize};
4use tracing::error;
5
6use openapi_nexus_core::NamingConvention;
7
8#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct GoHttpConfig {
11 #[serde(default = "default_file_naming_convention")]
13 pub file_naming_convention: NamingConvention,
14
15 #[serde(default)]
17 pub module_path: Option<String>,
18
19 #[serde(default)]
21 pub package_name: Option<String>,
22}
23
24fn default_file_naming_convention() -> NamingConvention {
25 NamingConvention::SnakeCase
26}
27
28impl Default for GoHttpConfig {
29 fn default() -> Self {
30 Self {
31 file_naming_convention: default_file_naming_convention(),
32 module_path: None,
33 package_name: None,
34 }
35 }
36}
37
38impl From<toml::value::Table> for GoHttpConfig {
39 fn from(value: toml::value::Table) -> Self {
40 use serde::Deserialize;
41 match GoHttpConfig::deserialize(value) {
42 Ok(config) => config,
43 Err(e) => {
44 error!(
45 "Failed to parse Go HTTP config: {}. Using default configuration.",
46 e
47 );
48 Self::default()
49 }
50 }
51 }
52}