Skip to content

goctl api dart generates http api error #4777

@ijkbytes

Description

@ijkbytes

Describe the bug
When running the goctl api dart command with a specified API file which has embed struct, it fails with an error indicating a template execution failure. The error occurs when trying to call the getPropertyFromMember function on an empty string.

To Reproduce
Steps to reproduce the behavior, if applicable:

  1. The API is
syntax = "v1"

type (
	Common {
		ID int `json:"id"`
	}
	HealthReq {}
	HealthRsp {
        Common
    }
)

@server (
	prefix: /test
	group:  test
)
service main {
	@handler GetSomeTestHandler
	get /some-test (HealthReq) returns (HealthRsp)
}

  1. Run goctl api dart --hostname "xxx.com" --scheme "https" --api ./test.api --dir ./dark

  2. The error is

2025/04/12 11:53:22 template: dataTemplate:23:35: executing "dataTemplate" at <getPropertyFromMember .>: error calling getPropertyFromMember: cannot get property name of ""

Expected behavior
No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/goctlCategorizes issue or PR as related to goctl.kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions