feat: add dynamic attribute support for self-referential schemas - #3
Draft
claude[bot] wants to merge 1 commit into
Draft
feat: add dynamic attribute support for self-referential schemas#3claude[bot] wants to merge 1 commit into
claude[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011drBEhNrtGfnXQNsedmJLa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Brady Burke · Slack thread
Before / After
Before: This fork of
terraform-plugin-codegen-frameworkhad no support for thedynamicattribute type. Feeding it a provider-code-spec that contained adynamicattribute would fail withattribute type not defined, because there was no generator wired up for it.After: The framework recognizes
dynamicattributes in the spec and generates the correspondingschema.DynamicAttribute{...}plus the matchingtypes.Dynamicmodel field, for resources, data sources, and providers. This lets the generator consume specs that represent a self-referential schema edge as adynamicattribute (see the companion OpenAPI-codegen PR linked below) and emit compiling Go provider code.How
GeneratorDynamicAttributeininternal/resource,internal/datasource, andinternal/provider, mirroring the existing scalar (bool) generators:Schema()emitsschema.DynamicAttribute{...},ModelField()emits atypes.Dynamicfield, plusImports,Equal,AttrType/AttrValue.a.Dynamic != nilcase toNewAttributein each of the threeconvert.gofiles.GeneratorDynamicAttributevalue added to theschema.Typeenum,DynamicValueType = "types.Dynamic"added tointernal/model, andDynamicentries added to thePlanModifierType/ValidatorTypeenums so custom plan modifiers/validators for dynamic attributes resolve correctly.New,Schema,ModelField).Known scope limit:
AssociatedExternalType/custom-type rendering and spec-leveldefaultfor dynamic attributes are not emitted (the upstream self-referential use case never sets them); this can be extended later if needed.Cross-dependency
This PR pairs with the OpenAPI-codegen change that first emits
dynamicattributes for self-referential schemas — companion PR: starburstdata/terraform-plugin-codegen-openapi#2. Both are required for the end-to-end codegen pipeline to succeed on the recursiveingest_columnschema.go build ./...andgo test ./internal/...pass (including the new dynamic tests; the existing golden-fileinternal/cmdtests are unaffected).Generated by Claude Code