-
-
Notifications
You must be signed in to change notification settings - Fork 559
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
How to define a ResultType for Cycle struct? #2514
Comments
@JermineHu To define cyclic attributes here is what you need to do var CategoryResult = ResultType("application/vnd.category", func() {
TypeName("CategoryResult") <--- Set a type name for your type
Attributes(func() {
Field(1, "id", Int, "ID")
Field(3, "children_category", ArrayOf("CategoryResult")) <---- Put the type name in quotes
Field(4, "name", String, "name")
})
}) This above DSL will create a type like this in the generated service code // CategoryResult is the result type of the calc service addurd method.
type CategoryResult struct {
// ID
ID *int
ChildrenCategory []*CategoryResult
// name
Name *string
} Is this what you were trying to achieve? If you are using this type on a HTTP endpoint you should be good to go. However, if you are using it on a GRPC endpoint there seems to be a bug in Goa which I have filed separately here - #2515 |
You did find another bug when trying to define cyclic types using CollectionOf. That should be fixed in this PR.
|
@nitinmohan87 Thank you for your contribution. Your code solved my problem in HTTP endpoints. Look forward to issue #2515 be solved. |
My first time try code
My DSL
The error info
My second time try code
My DSL
The error info
My question
How to define a struct like the follow code in goa by DSL ?
The text was updated successfully, but these errors were encountered: