@@ -37,7 +37,7 @@ fn generate_go(root: RootSchema) -> Result<String> {
37
37
for ( name, additional_type) in & root. definitions {
38
38
additional_type
39
39
. object ( )
40
- . map ( |def| build_type ( & replace_acronyms ( name) , def, & mut types) )
40
+ . map ( |def| build_type ( name, def, & mut types) )
41
41
. and_then ( |r| r)
42
42
. context ( "failed to generate additional definitions" ) ?;
43
43
}
@@ -107,7 +107,7 @@ pub fn build_struct(
107
107
let fields = fields. collect :: < Result < Vec < _ > > > ( ) ?;
108
108
109
109
Ok ( GoStruct {
110
- name : to_pascal_case ( name) ,
110
+ name : replace_acronyms ( to_pascal_case ( name) ) ,
111
111
docs,
112
112
fields,
113
113
} )
@@ -121,6 +121,7 @@ pub fn build_enum<'a>(
121
121
variants : impl Iterator < Item = & ' a Schema > ,
122
122
additional_structs : & mut Vec < GoStruct > ,
123
123
) -> Result < GoStruct > {
124
+ let name = replace_acronyms ( name) ;
124
125
let docs = documentation ( enm) ;
125
126
126
127
// go through all fields
@@ -131,18 +132,14 @@ pub fn build_enum<'a>(
131
132
. with_context ( || format ! ( "expected schema object for enum variants of {name}" ) ) ?;
132
133
133
134
// analyze the variant
134
- let variant_field = build_enum_variant ( v, name, additional_structs)
135
+ let variant_field = build_enum_variant ( v, & name, additional_structs)
135
136
. context ( "failed to extract enum variant" ) ?;
136
137
137
138
anyhow:: Ok ( variant_field)
138
139
} ) ;
139
140
let fields = fields. collect :: < Result < Vec < _ > > > ( ) ?;
140
141
141
- Ok ( GoStruct {
142
- name : name. to_string ( ) ,
143
- docs,
144
- fields,
145
- } )
142
+ Ok ( GoStruct { name, docs, fields } )
146
143
}
147
144
148
145
/// Tries to extract the name and type of the given enum variant and returns it as a `GoField`.
0 commit comments