-
Notifications
You must be signed in to change notification settings - Fork 11
spec: Add ObjectType with CustomType #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reference: #25 This breaking change ensures there is consistency that specification implementations can use `CustomType` with all types, in this case object types underlying any attribute type. For existing implementations, such as: ```json { "name": "list_object_attribute", "list": { "computed_optional_required": "computed", "element_type": { "object": [ { "name": "obj_string_attr", "string": {} } ] } } }, ``` Are now defined as: ```json { "name": "list_object_attribute", "list": { "computed_optional_required": "computed", "element_type": { "object": { "attribute_types": [ { "name": "obj_string_attr", "string": {} } ] } } } }, ``` Note that there is now a slight inconsistency between how `CustomType` is defined on collection types (`ListType`, `MapType`, and `SetType`) that are already element types and need to include their own element type. The `CustomType` is specified along side the element type, rather than explicitly having an `ElementType` delineation. Currently: ```json { "name": "map_list_string_attribute", "map": { "computed_optional_required": "computed", "element_type": { "list": { "custom_type": { "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes", "type": "basetypes.ListType", "value_type": "basetypes.ListValue" }, "string": {} } } } }, ``` It may make sense to reintroduce what was originally designed in the specification with the verbose `ElementType` property for clarity. ```json { "name": "map_list_string_attribute", "map": { "computed_optional_required": "computed", "element_type": { "list": { "custom_type": { "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes", "type": "basetypes.ListType", "value_type": "basetypes.ListValue" }, "element_type": { "string": {} } } } } }, ```
austinvalle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense to me 🚀 - I opened hashicorp/terraform-plugin-codegen-openapi#17 to update the OpenAPI generator
…ect property Reference: #26 For consistency with collection attribute types which use an explicit `element_type` object property and object types which use an explicit `attribute_types` property. An additional benefit is that it further distinguishes where a `custom_type` may apply. Previous implementations: ```json { "name": "list_map_attribute", "list": { "computed_optional_required": "computed", "element_type": { "map": { "string": {} } } } }, ``` Are now defined as: ```json { "name": "list_map_attribute", "list": { "computed_optional_required": "computed", "element_type": { "map": { "element_type": { "string": {} } } } } }, ``` The Go bindings and any consuming code do not require changes since Go implicitly required the `ElementType` field definition, even when it was using type embedding.
…ect property (#29) Reference: #26 For consistency with collection attribute types which use an explicit `element_type` object property and object types which use an explicit `attribute_types` property. An additional benefit is that it further distinguishes where a `custom_type` may apply. Previous implementations: ```json { "name": "list_map_attribute", "list": { "computed_optional_required": "computed", "element_type": { "map": { "string": {} } } } }, ``` Are now defined as: ```json { "name": "list_map_attribute", "list": { "computed_optional_required": "computed", "element_type": { "map": { "element_type": { "string": {} } } } } }, ``` The Go bindings and any consuming code do not require changes since Go implicitly required the `ElementType` field definition, even when it was using type embedding.
|
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. |
Closes #25
This breaking change ensures there is consistency that specification implementations can use
CustomTypewith all types, in this case object types underlying any attribute type.For existing implementations, such as:
{ "name": "list_object_attribute", "list": { "computed_optional_required": "computed", "element_type": { "object": [ { "name": "obj_string_attr", "string": {} } ] } } },Are now defined as:
{ "name": "list_object_attribute", "list": { "computed_optional_required": "computed", "element_type": { "object": { "attribute_types": [ { "name": "obj_string_attr", "string": {} } ] } } } },Note that there is now a slight inconsistency between how
CustomTypeis defined on collection types (ListType,MapType, andSetType) that are already element types and need to include their own element type. TheCustomTypeis specified along side the element type, rather than explicitly having anElementTypedelineation.Currently:
{ "name": "map_list_string_attribute", "map": { "computed_optional_required": "computed", "element_type": { "list": { "custom_type": { "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes", "type": "basetypes.ListType", "value_type": "basetypes.ListValue" }, "string": {} } } } },It may make sense to reintroduce what was originally designed in the specification with the verbose
ElementTypeproperty for clarity.{ "name": "map_list_string_attribute", "map": { "computed_optional_required": "computed", "element_type": { "list": { "custom_type": { "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes", "type": "basetypes.ListType", "value_type": "basetypes.ListValue" }, "element_type": { "string": {} } } } } },