@@ -23,7 +23,7 @@ pub struct Config {
2323pub fn analyze ( schema : JSONSchemaProps , kind : & str , cfg : Config ) -> Result < Output > {
2424 let mut res = vec ! [ ] ;
2525
26- analyze_ ( & schema, "" , & kind. to_upper_camel_case ( ) , 0 , & mut res, & cfg) ?;
26+ analyze_ ( & schema, "" , kind, 0 , & mut res, & cfg) ?;
2727 Ok ( Output ( res) )
2828}
2929
@@ -45,6 +45,8 @@ fn analyze_(
4545 let props = schema. properties . clone ( ) . unwrap_or_default ( ) ;
4646 let mut array_recurse_level: HashMap < String , u8 > = Default :: default ( ) ;
4747
48+ let camel_cased_stack = & stack. to_upper_camel_case ( ) ;
49+
4850 // create a Container if we have a container type:
4951 //trace!("analyze_ with {} + {}", current, stack);
5052 if schema. type_ . clone ( ) . unwrap_or_default ( ) == "object" {
@@ -55,29 +57,29 @@ fn analyze_(
5557 // object with additionalProperties == map
5658 if let Some ( extra_props) = & s. properties {
5759 // map values is an object with properties
58- debug ! ( "Generating map struct for {} (under {})" , current, stack ) ;
59- let c = extract_container ( extra_props, stack , & mut array_recurse_level, level, schema, cfg) ?;
60+ debug ! ( "Generating map struct for {} (under {})" , current, camel_cased_stack ) ;
61+ let c = extract_container ( extra_props, camel_cased_stack , & mut array_recurse_level, level, schema, cfg) ?;
6062 results. push ( c) ;
6163 } else if dict_type == "object" {
6264 // recurse to see if we eventually find properties
6365 debug ! (
6466 "Recursing into nested additional properties for {} (under {})" ,
65- current, stack
67+ current, camel_cased_stack
6668 ) ;
67- analyze_ ( s, current, stack , level, results, cfg) ?;
69+ analyze_ ( s, current, camel_cased_stack , level, results, cfg) ?;
6870 } else if !dict_type. is_empty ( ) {
6971 warn ! ( "not generating type {} - using {} map" , current, dict_type) ;
7072 return Ok ( ( ) ) ; // no members here - it'll be inlined
7173 }
7274 } else {
7375 // else, regular properties only
74- debug ! ( "Generating struct for {} (under {})" , current, stack ) ;
76+ debug ! ( "Generating struct for {} (under {})" , current, camel_cased_stack ) ;
7577 // initial analysis of properties (we do not recurse here, we need to find members first)
7678 if props. is_empty ( ) && schema. x_kubernetes_preserve_unknown_fields . unwrap_or ( false ) {
7779 warn ! ( "not generating type {} - using map" , current) ;
7880 return Ok ( ( ) ) ;
7981 }
80- let c = extract_container ( & props, stack , & mut array_recurse_level, level, schema, cfg) ?;
82+ let c = extract_container ( & props, camel_cased_stack , & mut array_recurse_level, level, schema, cfg) ?;
8183 results. push ( c) ;
8284 }
8385 }
@@ -91,10 +93,10 @@ fn analyze_(
9193 // again; additionalProperties XOR properties
9294 let extras = if let Some ( JSONSchemaPropsOrBool :: Schema ( s) ) = schema. additional_properties . as_ref ( ) {
9395 let extra_props = s. properties . clone ( ) . unwrap_or_default ( ) ;
94- find_containers ( & extra_props, stack , & mut array_recurse_level, level, schema, cfg) ?
96+ find_containers ( & extra_props, camel_cased_stack , & mut array_recurse_level, level, schema, cfg) ?
9597 } else {
9698 // regular properties only
97- find_containers ( & props, stack , & mut array_recurse_level, level, schema, cfg) ?
99+ find_containers ( & props, camel_cased_stack , & mut array_recurse_level, level, schema, cfg) ?
98100 } ;
99101 results. extend ( extras) ;
100102
0 commit comments