@@ -404,7 +404,10 @@ fn array_recurse_for_type(
404404 "integer" => Ok ( ( format ! ( "Vec<{}>" , extract_integer_type( value) ?) , level) ) ,
405405 "array" => {
406406 if s. items . is_some ( ) {
407- Ok ( array_recurse_for_type ( s, stack, key, level + 1 , cfg) ?)
407+ let ( array_type, recurse_level) =
408+ array_recurse_for_type ( s, stack, key, level + 1 , cfg) ?;
409+
410+ Ok ( ( format ! ( "Vec<{}>" , array_type) , recurse_level) )
408411 } else if cfg. relaxed {
409412 warn ! ( "Empty inner array in: {} key: {}" , stack, key) ;
410413 let map_type = cfg. map . name ( ) ;
@@ -1503,4 +1506,33 @@ type: object
15031506 ) ;
15041507 assert_eq ! ( structs[ 1 ] . name, "CephClusterSpecCephConfigFromSecret" ) ;
15051508 }
1509+
1510+ #[ test]
1511+ fn array_of_array ( ) {
1512+ init ( ) ;
1513+ let schema_str = r#"
1514+ properties:
1515+ mounts:
1516+ description: mounts specifies a list of mount points to be setup.
1517+ items:
1518+ description: MountPoints defines input for generated mounts in cloud-init.
1519+ items:
1520+ type: string
1521+ type: array
1522+ type: array
1523+ type: object
1524+ "# ;
1525+
1526+ let schema: JSONSchemaProps = serde_yaml:: from_str ( schema_str) . unwrap ( ) ;
1527+
1528+ let structs = analyze ( schema, "KubeadmConfig" , Cfg :: default ( ) ) . unwrap ( ) . 0 ;
1529+
1530+ let root = & structs[ 0 ] ;
1531+ assert_eq ! ( root. name, "KubeadmConfig" ) ;
1532+ assert_eq ! ( root. level, 0 ) ;
1533+
1534+ let map = & root. members [ 0 ] ;
1535+ assert_eq ! ( map. name, "mounts" ) ;
1536+ assert_eq ! ( map. type_, "Option<Vec<Vec<String>>>" ) ;
1537+ }
15061538}
0 commit comments