func combineFieldsRecursively()

in provider-schema/processors/combine.go [67:123]


func combineFieldsRecursively(resourceName string, schemaBlock *schema.SchemaBlock, markdownProps model.Properties, fields map[string]*schema.SchemaAttribute, attributePath string) {
	// Inject descriptions for attributes (fields)
	for fieldName, schemaField := range schemaBlock.Attributes {
		schemaField.Name = fieldName
		schemaField.ResourceOrDataSourceName = resourceName
		schemaField.AttributePath = buildAttributePath(attributePath, fieldName)

		if markdownProps != nil {
			markdownField := markdownProps[fieldName]

			if markdownField != nil {
				schemaField.Content = getDescription(markdownField.Content)
				schemaField.PossibleValues = markdownField.PossibleValues()
			} else {
				fmt.Printf("(TerraformObject %s) Field not found in documentation: %s\n", resourceName, schemaField.AttributePath)
			}
		}

		fields[schemaField.Name] = schemaField
	}

	// Inject descriptions for nested blocks
	for blockName, schemaBlockType := range schemaBlock.NestedBlocks {
		combinedBlockField := &schema.SchemaAttribute{
			Name:                     blockName,
			AttributeType:            schemaBlockType.Block.ImpliedType(),
			Required:                 schemaBlockType.Required,
			Optional:                 schemaBlockType.Optional,
			Computed:                 schemaBlockType.Computed,
			ConflictsWith:            schemaBlockType.ConflictsWith,
			ExactlyOneOf:             schemaBlockType.ExactlyOneOf,
			AtLeastOneOf:             schemaBlockType.AtLeastOneOf,
			RequiredWith:             schemaBlockType.RequiredWith,
			ResourceOrDataSourceName: resourceName,
			AttributePath:            buildAttributePath(attributePath, blockName),
			NestingMode:              schemaBlockType.NestingMode,
			Fields:                   make(map[string]*schema.SchemaAttribute),
		}

		// Inject description from markdown if available
		if markdownProps != nil {
			markdownBlockProps := markdownProps.FindAllSubBlock(blockName)
			if len(markdownBlockProps) > 0 {
				// Use the first field's description as the block description
				combinedBlockField.Content = getDescription(markdownBlockProps[0].Content)
				combinedBlockField.PossibleValues = markdownBlockProps[0].PossibleValues()

				// Inject descriptions for nested attributes
				combineFieldsRecursively(resourceName, schemaBlockType.Block, markdownBlockProps[0].Subs, combinedBlockField.Fields, combinedBlockField.AttributePath)
			} else {
				fmt.Printf("(TerraformObject %s) Block not found in documentation: %s\n", resourceName, combinedBlockField.AttributePath)
			}
		}

		fields[combinedBlockField.Name] = combinedBlockField
	}
}