grpc-ecosystem/protoc-gen-grpc-gateway-ts

Google-recommended way of structuring resource path is not supported (https://google.aip.dev/127)

Gugic opened this issue · 2 comments

Gugic commented

Hi, I am trying to setup grpc-gateway for the service and doing it using Google AIP recommendations and provided linter.

So if you would take a look at https://google.aip.dev/127 - the recommended way of using http annotations for more or less complicated APIs looks like that:

post: "/v1/{parent=publishers/*}/books"

However protoc-gen-grpc-gateway-ts would not generate expected for that case /v1/${req["parent"]}/books, instead of that protoc-gen-grpc-gateway-ts would generate /v1/${req["parentpublishers"]}/books

Gugic commented

There is also more complicated, but also commonly used case when (e.g. for update requests) nested field is used as a part of resource path, look at the Dialogflow proto for example: https://github.com/googleapis/googleapis/blob/master/google/cloud/dialogflow/cx/v3/intent.proto#L80

They have

    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };

That technically should be translated into /v3/${req["intent"]["name"]}

grpc-gateway itself fully supporting such a usecase

👋 @Gugic protoc-gen-grpc-gateway didn't cover this edge case yet unfortunately. However, contributions are welcome, ping me in a PR we can go from there.