-
-
Notifications
You must be signed in to change notification settings - Fork 554
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
CollectionOf()
+ View()
leading to unknown attribute errors.
#3546
Comments
The following generated successfully for me: package design
import . "goa.design/goa/v3/dsl"
var _ = Service("service", func() {
Method("list_resources", func() {
Result(CollectionOf(Resource), func() {
View("some_view")
})
})
})
var Resource = ResultType("application/vnd.goa.resource", "Resource", func() {
Attributes(func() {
Attribute("id", String, "Unique identifier of the resource")
})
View("some_view", func() {
Description("Some useful view")
Attribute("id")
})
}) Would you have a small repro I could try? |
Indeed a slightly more complex scenario is at play. I threw a branch up with a repro example here. EDIT: After pushing this to git, all of a sudden I stopped seeing the issue in my example. So I have yet to get to the bottom of it. |
Alright, I had some time to sit down and run through some scenarios. The original error disappeared, at one point reappeared, then quickly disappeared again without any clear causation I've been able to deduce. However! I am able to recreate what I'm starting to believe is the culprit behind whatever 👻 bug I've been chasing. It seems that Repro
Example// gen/as_json/service.go
// newRow converts projected type Row to service type Row.
func newRow(vres *asjsonviews.RowView) *Row {
res := &types.Row{
ID: vres.ID,
First: vres.First,
Last: vres.Last,
Email: vres.Email,
Ssn: vres.Ssn,
}
return res
} Internal to this generated function, If you replace |
Nice, for posterity here is a minimalistic design that reproduces the issue: package design
import (
. "goa.design/goa/v3/dsl"
)
var _ = Service("AsJson", func() {
Method("index", func() {
Result(CollectionOf(Row))
HTTP(func() { GET("/") })
})
})
var Row = ResultType("application/vnd.goa.row", "Row", func() {
Attributes(func() {
Field(0, "id", String, "Unique identifier a row")
})
Meta("struct:pkg:path", "types")
}) |
What seems to be the problem?
At least on the http service side of things, there seems to be a problem with generating the likes of...
where
types.Resource
is akin to ...goa gen results in...
Empirical findings.
CollectionOf
, leavingResult(types.Resource, func() { View("some_view") })
, gen runs cleanly.func() { View(...) }
, leavingResult(CollectionOf(types.Resource))
, gen runs cleanly.The text was updated successfully, but these errors were encountered: