Skip to content
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

google.api.http options in multi-line format not supported #16

Closed
sjincho opened this issue May 30, 2015 · 2 comments
Closed

google.api.http options in multi-line format not supported #16

sjincho opened this issue May 30, 2015 · 2 comments

Comments

@sjincho
Copy link

sjincho commented May 30, 2015

  rpc Echo(EchoRequest) returns (EchoReply) {
    // (1) works
    //option (google.api.http) = {
    //  post: "/v1/echo/echo"
    //  body: "*"
    //};
    // (2) doesn't work
    option (google.api.http).body = "*";
    option (google.api.http).post = "/v1/echo/echo";
  }

It seems like grpc-gateway compiler only supports aggregate TextFormat syntax. When using (2), compiler fails with error:

$ protoc -I. -I/usr/local/include -I../third_party/googleapis --grpc-gateway_out=logtostderr=true:. echo.proto
E0530 22:16:47.262160    6265 services.go:106] No pattern specified in google.api.HttpRule: Echo

According to the protobuf developers guide, both syntax are correct.
https://developers.google.com/protocol-buffers/docs/proto#options

@yugui
Copy link
Member

yugui commented Jun 1, 2015

Thank you for letting me know that. But it looks to be an issue in protoc or googleapis.
Let me confirm to the upstream.

Although the extension google.api.http in MethodOptions is an optional field, protoc emits as if it is a repeated field for the syntax (2). I am not sure what is the expected behavior.

Some possibilities come to my mind.

  1. protoc should have combined those lines into one extension if the two variations of syntax mean the same thing?
  2. goprotobuf should have done it?
  3. google.api.http should have been repeated field and grpc-gateway should have combine the repeated values into one?

Here is the dump of the code generation request.

...
    name: "EchoBody"
    input_type: ".gengo.grpc.gateway.example.SimpleMessage"
    output_type: ".gengo.grpc.gateway.example.SimpleMessage"
    options: <
      /* 38 unknown bytes */
      72295728: "\"\x15/v1/example/echo_body"
      72295728: ":\x01*"
    >

@sjincho
Copy link
Author

sjincho commented Jun 1, 2015

Hi Yuki,

I found: protocolbuffers/protobuf#59

So seems more like a protoc issue, unfortunately.

2015-06-01 22:10 GMT+09:00 Yuki Yugui Sonoda notifications@github.com:

Thank you for letting me know that. But it looks to be an issue in protoc
or googleapis.
Let me confirm to the upstream.

Although the extension google.api.http in MethodOptions is an optional
field, protoc emits as if it is a repeated field for the syntax (2). I am
not sure what is the expected behavior.

Some possibilities come to my mind.

  1. protoc should have combined those lines into one extension if the
    two variations of syntax mean the same thing?
  2. goprotobuf should have done it?
  3. google.api.http should have been repeated field and grpc-gateway
    should have combine the repeated values into one?

Here is the dump of the code generation request.

...
name: "EchoBody"
input_type: ".gengo.grpc.gateway.example.SimpleMessage"
output_type: ".gengo.grpc.gateway.example.SimpleMessage"
options: <
/* 38 unknown bytes /
72295728: ""\x15/v1/example/echo_body"
72295728: ":\x01
"
>


Reply to this email directly or view it on GitHub
#16 (comment).

@yugui yugui closed this as completed Jun 23, 2015
ithinker1991 referenced this issue in tronprotocol/grpc-gateway Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants