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

[Bug Report] Metadata() is not reflected when setting the Default() in goa design. #301

Open
nao1215 opened this issue Apr 17, 2024 · 0 comments

Comments

@nao1215
Copy link
Collaborator

nao1215 commented Apr 17, 2024

Goa design can use user-specific types as payload parameters through the use of Metadata(). However, the type specified in Metadata() is not reflected in the Default() setting.

Example (goa design)

var PagingType = Type("PagingType", func() {
	Param("limit", Integer, func() {
		Metadata("struct:field:type", "model.PagingLimit", "github.com/sample/model")
		Minimum(1)
		Default(20)
	})
})

Example (auto generated code, actual behavior)

// Finalize sets the default values for pagingType type instance.
func (ut *pagingType) Finalize() {
	var defaultLimit = 20
	if ut.Limit == nil {
		ut.Limit = &defaultLimit   // ⭐️ Bug. type mismatch.
	}
}

Expected behavior

Goa generates the following code:

func (ut *pagingType) Finalize() {
	var defaultLimit model.PagingLimit = 20
	if ut.Limit == nil {
		ut.Limit = &defaultLimit
	}
}
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