-
-
Notifications
You must be signed in to change notification settings - Fork 575
Closed
Description
It was an incorrect design that caused this, but instead of issuing an error during goa gen, it generated conflicting type definitions.
Tested with v3.22.1
% go list -m goa.design/goa/v3
goa.design/goa/v3 v3.22.1package design
import . "goa.design/goa/v3/dsl"
var _ = API("MyAPI", func() {})
var _ = Service("MyService", func() {
Method("a", func() {
Payload(Empty)
Result(TypeA)
})
Method("b", func() {
Payload(Empty)
Result(TypeB)
})
})
var TypeA = ResultType("application/vnd.example.com.a", func() {
TypeName("A")
Attribute("a", Int)
})
var TypeB = ResultType("application/vnd.example.com.b", func() {
TypeName("A") // ❌ mistake
Attribute("b", String)
})Among other problems this yields the following. Note the two definitions of type AView, newA and newAView.
% grep -R type\ A
gen/my_service/views/view.go:type A struct {
gen/my_service/views/view.go:type AView struct {
gen/my_service/views/view.go:type AView struct {
gen/my_service/views/view.go:// ValidateA runs the validations defined on the viewed result type A.
gen/my_service/service.go:type A struct {
gen/my_service/service.go:// NewA initializes result type A from viewed result type A.
gen/my_service/service.go:// NewViewedA initializes viewed result type A from result type A using the
gen/my_service/service.go:// newA converts projected type A to service type A.
gen/my_service/service.go:// newAView projects result type A to projected type AView using the "default"
gen/my_service/service.go:// newA converts projected type A to service type A.
gen/my_service/service.go:// newAView projects result type A to projected type AView using the "default"Metadata
Metadata
Assignees
Labels
No labels