Skip to content

Commit d75929a

Browse files
authored
Fix panic on config file generation (1Password#153)
1 parent a905fc1 commit d75929a

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cli/src/config.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ pub struct ScalaParams {
3131
#[serde(default)]
3232
pub struct SwiftParams {
3333
pub prefix: String,
34-
pub type_mappings: HashMap<String, String>,
3534
pub default_decorators: Vec<String>,
3635
pub default_generic_constraints: Vec<String>,
3736
/// The contraints to apply to `CodableVoid`.
3837
pub codablevoid_constraints: Vec<String>,
38+
pub type_mappings: HashMap<String, String>,
3939
}
4040

4141
#[derive(Default, Serialize, Deserialize, PartialEq, Eq, Debug)]
@@ -49,8 +49,8 @@ pub struct TypeScriptParams {
4949
#[cfg(feature = "go")]
5050
pub struct GoParams {
5151
pub package: String,
52-
pub type_mappings: HashMap<String, String>,
5352
pub uppercase_acronyms: Vec<String>,
53+
pub type_mappings: HashMap<String, String>,
5454
}
5555

5656
/// The paramters that are used to configure the behaviour of typeshare
@@ -126,6 +126,14 @@ mod test {
126126
[CURRENT_DIR, TEST_DIR, filename].iter().collect()
127127
}
128128

129+
#[test]
130+
fn to_string_and_back() {
131+
let path = config_file_path("mappings_config.toml");
132+
let config = load_config(Some(path)).unwrap();
133+
134+
toml::from_str::<Config>(&toml::to_string_pretty(&config).unwrap()).unwrap();
135+
}
136+
129137
#[test]
130138
fn default_test() {
131139
let path = config_file_path("default_config.toml");

0 commit comments

Comments
 (0)