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-recommended way of structuring resource path is not supported (https://google.aip.dev/127) #28

Open
Gugic opened this issue Nov 6, 2021 · 2 comments · May be fixed by #31 or #47
Open

Comments

@Gugic
Copy link

Gugic commented Nov 6, 2021

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
Copy link
Author

Gugic commented Nov 6, 2021

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

@lyonlai
Copy link
Collaborator

lyonlai commented Nov 11, 2021

👋 @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.

mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
@mbarrien mbarrien linked a pull request Mar 30, 2022 that will close this issue
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
mbarrien added a commit to mbarrien/protoc-gen-grpc-gateway-ts that referenced this issue Mar 30, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
yeluyang pushed a commit to yeluyang/protoc-gen-grpc-gateway-ts that referenced this issue Oct 10, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
yeluyang pushed a commit to yeluyang/protoc-gen-grpc-gateway-ts that referenced this issue Oct 11, 2022
Closes grpc-ecosystem#28

Adds support for 2 related cases in URLs:
* Support path segments like in https://google.aip.dev/127, where the
  URL contains a pattern like `post: "/v1/{parent=publishers/*}/books"`
* Support nested field names in the URL, where the URL is structured
  like:
  ```
    option (google.api.http) = {
      patch: "/v3/{intent.name=projects/*/locations/*/agents/*/intents/*}"
      body: "intent"
    };
  ```
  This gets translated to `/v3/${req["intent"]["name"]}`

While here, use the newer protoc-gen-go-grpc plugin for generating
server test code, due to deprecated usage of plugin=grpc (see
https://github.com/protocolbuffers/protobuf-go/releases/tag/v1.20.0#v1.20-grpc-support)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants