diff --git a/CHANGELOG.md b/CHANGELOG.md index 69cbeb08..457dc2bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,11 @@ ENHANCEMENTS: * template functions: Added `split` to help separating a string into substrings ([#70](https://github.com/hashicorp/terraform-plugin-docs/pull/70)). - + +BUG FIXES: + +* schemamd: By default `ID` attribute should be "Read Only", unless there's a description defined, in which case it's handled like any other attribute in the schema ([#46](https://github.com/hashicorp/terraform-plugin-docs/pull/46)). + # 0.7.0 (March 15, 2022) ENHANCEMENTS: diff --git a/schemamd/render.go b/schemamd/render.go index 68568c6d..dbf86087 100644 --- a/schemamd/render.go +++ b/schemamd/render.go @@ -70,10 +70,6 @@ func writeAttribute(w io.Writer, path []string, att *tfjson.SchemaAttribute, gro return nil, err } - if name == "id" && att.Description == "" { - att.Description = "The ID of this resource." - } - if att.AttributeNestedType == nil { err = WriteAttributeDescription(w, att, false) } else { @@ -225,7 +221,13 @@ nameLoop: } } else if childAtt, ok := block.Attributes[n]; ok { for i, gf := range groupFilters { - if gf.filterAttribute(childAtt) { + if strings.ToLower(n) == "id" && childAtt.Description == "" { + if gf.topLevelTitle == "Read-Only" { + childAtt.Description = "The ID of this resource." + groups[i] = append(groups[i], n) + continue nameLoop + } + } else if gf.filterAttribute(childAtt) { groups[i] = append(groups[i], n) continue nameLoop }