rules-proto-grpc / rules_proto_grpc

Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
https://rules-proto-grpc.com
Apache License 2.0
249 stars 156 forks source link

rust: JSON compliant casing #297

Closed maghoff closed 8 months ago

maghoff commented 8 months ago

Quoting 1:

By default proto3 JSON printer should convert the field name to lowerCamelCase and use that as the JSON name. An implementation may provide an option to use proto field name as the JSON name instead.

The serde plugin does this correctly, but when the rules specify the preserve_proto_field_names option, two things happen:

  1. The generated serde code preserves the proto field names (instead of converting the casing as it should)
  2. The user of these bazel rules cannot override the choice

If, instead, rules_proto_grpc avoids specifying this flag, it can be optionally added to the rust_prost_proto_library invocation in user code via options:

options = {
    "//rust:rust_serde_plugin": ["preserve_proto_field_names"],
},

Thus, the better default is to leave out this flag from rules_proto_grpc and instead allow the user to choose.