hashicorp / hashicorp/terraform-plugin-codegen-openapi

Expose the `tags.description` field in the Open API spec to use as resource/data source schema description

Open
#123 5 comments 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
91
Forks
20
Avg merge
2d 13h
Merged PRs (30d)
1

Description

### Use Cases or Problem Statement

The autogen tool does not populate the `Schema.Description` and `Schema.MarkdownDescription` fields for a TF resource or data source.

## Example:
### What is happening
```hcl
func DataSourceSchema(ctx context.Context) schema.Schema {
return schema.Schema{
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Computed: true,
Description: "Unique 24-hexadecimal digit string that identifies the search deployment.",
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the search deployment.",
},
"cluster_name": schema.StringAttribute{
Required: true,
Description: "Label that identifies the cluster to return the search nodes for.",
MarkdownDescription: "Label that identifies the cluster to return the search nodes for.",
},
"project_id": schema.StringAttribute{
Required: true,
Description: "Unique 24-hexadecimal digit string that identifies your project.",
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project.",
},
```

### Expectation

```hcl
func DataSourceSchema(ctx context.Context) schema.Schema {
return schema.Schema{
MarkdownDescription: "Provides a Search Deployment data source.",
Description: "Provides a Search Deployment data source.",
Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
Computed: true,
Description: "Unique 24-hexadecimal digit string that identifies the search deployment.",
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies the search deployment.",
},
"cluster_name": schema.StringAttribute{
Required: true,
Description: "Label that identifies the cluster to return the search nodes for.",
MarkdownDescription: "Label that identifies the cluster to return the search nodes for.",
},
"project_id": schema.StringAttribute{
Required: true,
Description: "Unique 24-hexadecimal digit string that identifies your project.",
MarkdownDescription: "Unique 24-hexadecimal digit string that identifies your project.",
}

```

### Proposal

Use the `tags.name` and `tags.description` in the OpenAPI spec to populate these fields. Another option would be to auto-populate these fields with a predefined format such as `"Define a data source for { .Name }."`

### Additional Information

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.