Skip to content

fix(goctl): support embedded structs in Dart generation - #5829

Open
Joey0v0 wants to merge 1 commit into
zeromicro:masterfrom
Joey0v0:fix/dart-embedded-struct
Open

Joey0v0 wants to merge 1 commit into
zeromicro:masterfrom
Joey0v0:fix/dart-embedded-struct

Conversation

@Joey0v0

@Joey0v0 Joey0v0 commented Oct 13, 2026

Copy link
Copy Markdown

Fixes #4777

When an API type embeds another struct, goctl api dart fails with
cannot get property name of "" because the generator treats the
anonymous embedded member as a named field.

This change expands embedded fields while preserving their tags and
converting their Dart types. It supports nested and pointer embeddings
in both data templates, and handles embedded path parameters.

Regression tests cover embedded structs, custom JSON tags, field
conflicts, and both API parsers.

Validation:

  • go test ./api/dartgen -count=1 passed.
  • go vet ./api/dartgen passed.
  • The API example from goctl api dart generates http api error #4777 generates successfully.
  • Full goctl tests fail in api/format, docker, util/ctx, and util/pathx
    on Windows. These failures were also reproduced with unmodified source.
  • Dart compilation was not checked because the Dart SDK is unavailable.

@kevwan kevwan added area/api Categorizes issue or PR as related to API syntax or usages. area/goctl Categorizes issue or PR as related to goctl. kind/bug Something isn't working labels Oct 31, 2026
@kevwan
kevwan force-pushed the fix/dart-embedded-struct branch from ac1a1c2 to f3cfc1f Compare November 5, 2026 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/api Categorizes issue or PR as related to API syntax or usages. area/goctl Categorizes issue or PR as related to goctl. kind/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

goctl api dart generates http api error

2 participants