goadesign / goa

šŸŒŸ Goa: Elevate Go API development! šŸš€ Streamlined design, automatic code generation, and seamless HTTP/gRPC support. āœØ
https://goa.design
MIT License
5.66k stars 557 forks source link

The StreamingPayload generates broken code #2664

Closed JermineHu closed 4 years ago

JermineHu commented 4 years ago

My dsl code:

    Method("broker", func() {
        NoSecurity()
        Payload(func() {
            Field(1, "token", String, "JWTAuth token used to perform authorization", func() {
            })
            Field(2, "host_id", UInt64, "host_id", func() {
            })
            Required("host_id")
        })

        StreamingPayload(func() {
            Field(1, "type", String, "type value", func() {
                Enum("heartbeat", "keyboard")
            })
            Field(2, "keyboard_info", Keyboard, "keyboard info")
            Field(3, "ext", String, "other info")
        })
        StreamingResult(func() {
                        Field(1, "type", String, "type value", func() {
                Enum("heartbeat", "keyboard")
            })
            Field(2, "keyboard_info", Keyboard, "keyboard info")
            Field(3, "ext", String, "other info")
        })

        Error("BadRequest")
        HTTP(func() {
            GET("/broker/{host_id}")
            Response(StatusOK)
            Header("token:Authorization", String, "Auth token", func() {
                //Pattern("^Bearer [^ ]+$")
            })
            Response("BadRequest", StatusBadRequest)
        })

        GRPC(func() {
            Response(CodeOK)        
            Response("BadRequest", CodeFailedPrecondition)
        })
    })

My code compile error info :

../../gen/http/keyboard/server/websocket.go:133:36: cannot use &body (type **BrokerStreamingBody) as type *BrokerStreamingBody in argument to ValidateBrokerStreamingBody
raphael commented 4 years ago

Thank you for the detailed report, looks like a bug.

raphael commented 4 years ago

Thank you for the report and for including a repro. This is now fixed.