Support nested fields, path segments#31
Open
mbarrien wants to merge 2 commits intogrpc-ecosystem:masterfrom
Open
Support nested fields, path segments#31mbarrien wants to merge 2 commits intogrpc-ecosystem:masterfrom
mbarrien wants to merge 2 commits intogrpc-ecosystem:masterfrom
Conversation
a9d09c1 to
3b14d8a
Compare
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)
3b14d8a to
07fb69d
Compare
mckelveygreg
suggested changes
Mar 30, 2022
mckelveygreg
left a comment
There was a problem hiding this comment.
I got this to generate a lovely client with your changes!
One suggestion is in order to make strict typescript happy, you'll need to do a null check on the nested fields because they are optional.
mckelveygreg
approved these changes
Mar 31, 2022
| } | ||
| fieldName := strings.Join(subFieldNames, ".") | ||
| part := fmt.Sprintf(`${req%s}`, strings.Join(partNames, "")) | ||
| part := fmt.Sprintf(`${req%s}`, strings.Join(partNames, "?.")) |
There was a problem hiding this comment.
Thanks! This worked great for me!
|
This fix works perfect for our use case, please merge it. @mbarrien |
|
we really need this patch, can someone do some magic and make ci happy ? 😭 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #28
Adds support for 2 related cases in URLs:
URL contains a pattern like
post: "/v1/{parent=publishers/*}/books"like:
/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)