hashicorp / hashicorp/terraform-plugin-codegen-openapi

Consider adding nested block support as alternative to nested attribute

Open
#106 1 comment 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

Currently, the OpenAPI provider spec generator will always default to [nested attributes](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/attributes#nested-attribute-types) when generating resource/data source/provider schemas with structural/collection types. This however requires that a provider be implemented with protocol v6 support and may not be desired for provider developers who want to use this tool for migrating from SDKv2 to Framework.

The [provider code spec](https://developer.hashicorp.com/terraform/plugin/code-generation/specification#blocks) and [`tfplugingen-framework`](https://developer.hashicorp.com/terraform/plugin/code-generation/framework-generator#nested-blocks) already support blocks.

### Proposal

Implement support for generating [nested blocks](https://developer.hashicorp.com/terraform/plugin/framework/handling-data/blocks) which can be supported on protocol v5. We want to encourage using nested attributes whenever possible, so we could introduce this as an opt-in configuration per-resource.

### Example:
```yml
provider:
name: petstore

data_sources:
pet:
read:
path: /pet/{petId}
method: GET
schema:
# Object = SingleNestedBlock, Collection = ListNestedBlock, Set= SetNestedBlock
v5: true
```

There are likely some edge-cases we might not be able to handle or express fully with the code generator (such as maps), so we'll need to determine how best to surface this information to users.

### 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.