chore: demo of showcase with json_name#12980
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces new RPC methods (RepeatDataCustomPath, RepeatDataBodyCustomMessage, and RepeatDataCustomQuery) to the Compliance service, including the necessary proto definitions, client stubs, and tests. The review identified two high-severity issues in HttpJsonComplianceStub.java where json_name values were incorrectly used instead of proto field names for path parameters and request body mapping, which violates standard HTTP transcoding rules.
| "/v1beta1/repeat/{info.custom-path-field}:custompath", | ||
| request -> { | ||
| Map<String, String> fields = new HashMap<>(); | ||
| ProtoRestSerializer<CustomBindingRequest> serializer = | ||
| ProtoRestSerializer.create(); | ||
| serializer.putPathParam( | ||
| fields, | ||
| "info.custom-path-field", | ||
| request.getInfo().getCustomPathField()); |
There was a problem hiding this comment.
The path template and the parameter key in putPathParam use the json_name ("custom-path-field") instead of the proto field name ("custom_path_field"). According to AIP-127 and standard HTTP transcoding rules, path templates refer to proto field names. Using the json_name here is inconsistent with the proto definition (line 132 of compliance.proto) and also inconsistent with the routing header extraction logic later in this file (line 987), which correctly uses underscores.
| "/v1beta1/repeat/{info.custom-path-field}:custompath", | |
| request -> { | |
| Map<String, String> fields = new HashMap<>(); | |
| ProtoRestSerializer<CustomBindingRequest> serializer = | |
| ProtoRestSerializer.create(); | |
| serializer.putPathParam( | |
| fields, | |
| "info.custom-path-field", | |
| request.getInfo().getCustomPathField()); | |
| "/v1beta1/repeat/{info.custom_path_field}:custompath", | |
| request -> { | |
| Map<String, String> fields = new HashMap<>(); | |
| ProtoRestSerializer<CustomBindingRequest> serializer = | |
| ProtoRestSerializer.create(); | |
| serializer.putPathParam( | |
| fields, | |
| "info.custom_path_field", | |
| request.getInfo().getCustomPathField()); |
| request -> | ||
| ProtoRestSerializer.create() | ||
| .toBody( | ||
| "custom-body-message", request.getCustomBodyMessage(), false)) |
There was a problem hiding this comment.
The body parameter name in toBody should match the field name specified in the body option of the google.api.http annotation in the proto. The proto definition (line 140 of compliance.proto) uses the field name "custom_body_message", not the json_name "custom-body-message".
| "custom-body-message", request.getCustomBodyMessage(), false)) | |
| "custom_body_message", request.getCustomBodyMessage(), false)) |
No description provided.