buf icon indicating copy to clipboard operation
buf copied to clipboard

Add linter that enforces that json_name values are lower_snake_case

Open flc1125 opened this issue 1 year ago • 2 comments

message SubscribeResponse {
  string subscription_id = 1 [json_name = "subscription_id"]; // <-----
}

My requirement is that when generating PHP code via protobuf and using: serializeToJsonString directly,

if json_name is not defined, it will produce camel case. It looks like this: user_name -> userName.

flc1125 avatar Apr 30 '24 15:04 flc1125

Thanks for your request here. It's a fair issue, but we'll have to consider the implications. We are working on the ability to write custom lint plugins at the moment, and this may be a good candidate for a custom lint rule implemented outside of buf, given that there may not be a good consensus as to what style json_name values should be in. We'll keep this issue open as we work on custom lint plugins, and will keep you updated.

bufdev avatar May 18 '24 22:05 bufdev

This is an excellent approach. Looking forward to the release of new features.

flc1125 avatar May 20 '24 05:05 flc1125

We're cleaning up our issues, and we're going to close this as a "duplicate" of #29 - we're actively working on #29, so I'd encourage you to watch that issue for updates!

bufdev avatar Jun 13 '24 20:06 bufdev