grpc-ecosystem / grpc-gateway

gRPC to JSON proxy generator following the gRPC HTTP spec
https://grpc-ecosystem.github.io/grpc-gateway/
BSD 3-Clause "New" or "Revised" License
17.96k stars 2.21k forks source link

Support wkt.HttpBody as the body type in requests #1815

Open v3n opened 3 years ago

v3n commented 3 years ago

This is a tracking issue for an incoming contribution based on a conversation had with @johanbrandhorst in Slack.

v3n: Would you accept a PR to add HttpBody in requests? It’s a pattern that’s shown as an example in the google.api.http docs.

johanbrandhorst: Sure, what exactly is missing for this?

v3n: I’ve got it semi-working locally. To fix, I had the implement the Unmarshal , NewDecoder, and NewEncoderdefinitions for HttpBodyMarshaler. What’s missing right now is the propogation of Content-Type from the request into the HttpBody definition after unmarshaling the request body. To do that, I’ll probably need to add some HttpBody-specific generation logic to protoc-gen-gateway. Additionally, I’ll need to figure out how to represent HttpBody in OpenAPI and make protoc-gen-openapi2 produce the correct Swagger docs.

johanbrandhorst: I think we can split those into two steps, we already don't generate correct OpenAPI for httpbody AFAIK. But yeah, would love to see that contribution!

johanbrandhorst commented 3 years ago

Note that the HTTPBody swagger annotations are already subject to https://github.com/grpc-ecosystem/grpc-gateway/issues/1274.