Skip to content
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

Client generator: go embedded struct is not included in generated client #1692

Open
WillSewell opened this issue Jan 9, 2025 · 0 comments
Open

Comments

@WillSewell
Copy link

If I have an API like

type ExampleEmbedded struct {
	ExampleFieldInner string
}

type ExampleOuter struct {
	ExampleEmbedded
	ExampleFieldOuter string
}

type ExampleResponse struct {
	Example ExampleOuter
}

//encore:api public
func (s *Service) Example(ctx context.Context) (*ExampleResponse, error) {
	return &ExampleResponse{
		Example: ExampleOuter{
			ExampleEmbedded: ExampleEmbedded{
				ExampleFieldInner: "inner",
			},
			ExampleFieldOuter: "outer",
		},
	}, nil
}

and run encore gen client <app> --output=./client.ts --env=local, then I get

export interface ExampleOuter {
    ExampleFieldOuter: string
}

export interface ExampleResponse {
    Example: ExampleOuter
}

I think this is a bug, because if I actually make a request to the endpoint, then it does return fields from embedded structs.

{"Example":{"ExampleFieldInner":"inner","ExampleFieldOuter":"outer"}}
@WillSewell WillSewell changed the title Go client generator: embedded struct is not included in generated client Client generator: go embedded struct is not included in generated client Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant