-
Notifications
You must be signed in to change notification settings - Fork 927
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
Provide a way to ignore json_name
in HTTP/JSON transcoding
#6082
base: main
Are you sure you want to change the base?
Conversation
Motivation: There is a bug in protoc that always adds json_name to the descriptor. This happens by default when compiling proto files in Bazel. To mitigate this bug, I propose to add `HttpJsonTranscodingQueryParamMatchRule.IGORE_JSON` to forcibliy ignore json_name when matching query params or path variables. Modifications: - Add `HttpJsonTranscodingQueryParamMatchRule.INGORE_JSON` - If enabled, the `json_name` field option is ignored. Result: - Fixes line#5890 - You can now ignore the `json_name` field option when trancoding HTTP/JSON to gRPC messages.
@@ -172,16 +174,20 @@ static GrpcService of(GrpcService delegate, HttpJsonTranscodingOptions httpJsonT | |||
continue; | |||
} | |||
|
|||
// TODO(ikhoon): Extract the build-time code into a separate class such as | |||
// HttpJsonTranscodingServiceBuilder or HttpJsonTranscodingSpecGenerator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This class gets bigger and bigger. Looks like it needs some refactoring.
@mscheong01 I want to inform you of this change as you added the |
Motivation:
There is a bug in
protoc
that always adds json_name to the descriptor. protocolbuffers/protobuf#5587This happens by default when compiling proto files in Bazel. To mitigate this bug, I propose to add
HttpJsonTranscodingQueryParamMatchRule.JSON_NAME
to decide whether to use or ignore json_name when matching query params.Modifications:
HttpJsonTranscodingQueryParamMatchRule.JSON_NAME
json_name
field option is used to match query parameters.ORIGINAL_FIELD
orLOWER_CAMEL_CASE
[ORIGINAL_FIELD, JSON_NAME]
. the json_name is used only when there is no matching original field.HttpJsonTranscodingQueryParamMatchRule.JSON_NAME
is explicitly specified viaHttpJsonTranscodingOptionsBuilder.queryParamMatchRules()
. By default,JSON_NAME
is set.Result:
Fixes JSON transcoding has backwards incompatible change in 1.27.0, due to json_name field always populated by protoc #5890
You can now choose whether to use the
json_name
field option when transcoding HTTP/JSON to gRPC messages.