@@ -202,6 +202,16 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
202202 }
203203 if v .Required {
204204 opt := "Required"
205+ sub := getSubStruct (0 , k , v )
206+ subStruct = append (subStruct , sub ... )
207+ // get type
208+ res := parseSubtract (v , sub )
209+ valueType := parseType (v )
210+ if res == "" {
211+ opt += fmt .Sprintf (", %s" , valueType )
212+ } else {
213+ opt += fmt .Sprintf (", %s: [`%s`]" , valueType , res )
214+ }
205215 if v .ForceNew {
206216 opt += ", ForceNew"
207217 }
@@ -210,9 +220,18 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
210220 v .Description = fmt .Sprintf ("%s %s" , v .Deprecated , v .Description )
211221 }
212222 requiredArgs = append (requiredArgs , fmt .Sprintf ("* `%s` - (%s) %s" , k , opt , v .Description ))
213- subStruct = append (subStruct , getSubStruct (0 , k , v )... )
214223 } else if v .Optional {
215224 opt := "Optional"
225+ sub := getSubStruct (0 , k , v )
226+ subStruct = append (subStruct , sub ... )
227+ // get type
228+ res := parseSubtract (v , sub )
229+ valueType := parseType (v )
230+ if res == "" {
231+ opt += fmt .Sprintf (", %s" , valueType )
232+ } else {
233+ opt += fmt .Sprintf (", %s: [`%s`]" , valueType , res )
234+ }
216235 if v .ForceNew {
217236 opt += ", ForceNew"
218237 }
@@ -221,7 +240,6 @@ func genDoc(product, dtype, fpath, name string, resource *schema.Resource) {
221240 v .Description = fmt .Sprintf ("%s %s" , v .Deprecated , v .Description )
222241 }
223242 optionalArgs = append (optionalArgs , fmt .Sprintf ("* `%s` - (%s) %s" , k , opt , v .Description ))
224- subStruct = append (subStruct , getSubStruct (0 , k , v )... )
225243 } else {
226244 attrs := getAttributes (0 , k , v )
227245 if len (attrs ) > 0 {
@@ -348,12 +366,16 @@ func getSubStruct(step int, k string, v *schema.Schema) []string {
348366 for kk , vv := range v .Elem .(* schema.Resource ).Schema {
349367 if vv .Required {
350368 opt := "Required"
369+ valueType := parseType (vv )
370+ opt += fmt .Sprintf (", %s" , valueType )
351371 if vv .ForceNew {
352372 opt += ", ForceNew"
353373 }
354374 requiredArgs = append (requiredArgs , fmt .Sprintf ("* `%s` - (%s) %s" , kk , opt , vv .Description ))
355375 } else if vv .Optional {
356376 opt := "Optional"
377+ valueType := parseType (vv )
378+ opt += fmt .Sprintf (", %s" , valueType )
357379 if vv .ForceNew {
358380 opt += ", ForceNew"
359381 }
@@ -451,3 +473,35 @@ func message(msg string, v ...interface{}) {
451473 color .White (fmt .Sprintf (msg , v ... ))
452474 }
453475}
476+
477+ func parseType (v * schema.Schema ) string {
478+ res := ""
479+ switch v .Type {
480+ case schema .TypeBool :
481+ res = "Bool"
482+ case schema .TypeInt :
483+ res = "Int"
484+ case schema .TypeFloat :
485+ res = "Float64"
486+ case schema .TypeString :
487+ res = "String"
488+ case schema .TypeList :
489+ res = "List"
490+ case schema .TypeMap :
491+ res = "Map"
492+ case schema .TypeSet :
493+ res = "Set"
494+ }
495+ return res
496+ }
497+
498+ func parseSubtract (v * schema.Schema , subStruct []string ) string {
499+ res := ""
500+ if v .Type == schema .TypeSet || v .Type == schema .TypeList {
501+ if len (subStruct ) == 0 {
502+ vv := v .Elem .(* schema.Schema )
503+ res = parseType (vv )
504+ }
505+ }
506+ return res
507+ }
0 commit comments