-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
lncli+proto: use original name in jsonpb marshaler and remove json_name fields in proto #3996
Conversation
This is cool. Did you check that all fields get the exact same json names after doing it this way? In case we had typos in the manually crafted names... |
Hmm... Good thinking! // 1: autopilot.proto, message QueryScoresRequest
bool ignore_local_state = 2 [json_name = "no_state"];
// 2: rpc.proto, message Utxo:
AddressType type = 1 [json_name = "address_type"];
// 3: rpc.proto, message ChannelFeeReport:
string chan_point = 1 [json_name = "channel_point"];
// 4: rpc.proto, message PolicyUpdateRequest
bool min_htlc_msat_specified = 8 [json_name = "set_min_htlc_msat"];
|
👍
What if we change the proto field name to
same, rename to
How come both work? |
Yes, it looks like renaming Only projects using our code directly (
The |
thanks for looking into this @guggero. i'm okay the breaking changes for |
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.
So now we'll intentionally rename the grpc names for AddressType
and ChannelPoint
, while the other two ingore_local_state
and set_min_whatever
will work as before both for grpc and REST?
I think that sounds like a good solution.
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.
LGTM 👍
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.
@guggero needs rebase but otherwise LGTM
Because we now use printRespJSON everywhere where we print RPC responses as JSON, we can simply instruct the jsonpb marshaler to use the original snake_case name specified in the proto file for the JSON field names and not the default camelCase.
We now use the jsonpb marshaler to convert the RPC responses to JSON in lncli and REST. The jsonpb has a setting to use the original name as defined in the proto file and the explicit json_name definition is not necessary any more. The jsonpb setting is called OrigName and needs to be true.
We now use the jsonpb marshaler to convert the RPC responses to JSON in lncli and REST. The jsonpb has a setting to use the original name as defined in the proto file and the explicit json_name definition is not necessary any more. The jsonpb setting is called OrigName and needs to be true.
We now use the jsonpb marshaler to convert the RPC responses to JSON in lncli and REST. The jsonpb has a setting to use the original name as defined in the proto file and the explicit json_name definition is not necessary any more. The jsonpb setting is called OrigName and needs to be true.
We now use the jsonpb marshaler to convert the RPC responses to JSON in lncli and REST. The jsonpb has a setting to use the original name as defined in the proto file and the explicit json_name definition is not necessary any more. The jsonpb setting is called OrigName and needs to be true.
We now use the jsonpb marshaler to convert the RPC responses to JSON in lncli and REST. The jsonpb has a setting to use the original name as defined in the proto file and the explicit json_name definition is not necessary any more. The jsonpb setting is called OrigName and needs to be true.
We now use the jsonpb marshaler to convert the RPC responses to JSON in lncli and REST. The jsonpb has a setting to use the original name as defined in the proto file and the explicit json_name definition is not necessary any more. The jsonpb setting is called OrigName and needs to be true.
We now use the jsonpb marshaler to convert the RPC responses to JSON in lncli and REST. The jsonpb has a setting to use the original name as defined in the proto file and the explicit json_name definition is not necessary any more. The jsonpb setting is called OrigName and needs to be true.
Rebased. |
We now use the jsonpb marshaler to convert the RPC responses to JSON in lncli and REST.
The jsonpb has a setting (
OrigName: true
) to use the original name as defined in the proto file and the explicit json_name definition is not necessary any more.This PR also formats all
.proto
files to remove some inconsistencies with white space use.