grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.56k stars 762 forks source link

is there any way can keep the fieldname not change to camel-case? #1176

Open Mrluobo opened 2 years ago

Mrluobo commented 2 years ago

hi ,I try to use protoc-gen-grpc-web to build typescript types from proto file. it work well except the fieldname be changed to camel-case.

I fork this Repository and modify the CamelCaseJSFieldName function. then I make & make install on my macbook,it work fine.

but I'm poor on C++,i can not build a linux version to use in linux system like the release flie.

question is :

  1. can the plugin provide a option that do not change the fieldname to camel-case?
  2. how to cross-compile a linux version plugin on my mac-os?

Hope helps, thx

sampajano commented 2 years ago

Hi! Thanks for the question!


can the plugin provide a option that do not change the fieldname to camel-case?

The option to use under_score_names was discussed before. But the decision was to keep the camel-case filename due to it being more common for Typescript. (see https://github.com/grpc/grpc-web/pull/1168 for some context.)

While it's possible to introduce this as a new option in the compiler, it's maybe adding too much unnecessary complexity, given that it should be relatively easy for users in need to write a short script to rename the files after they're generated.. :)


how to cross-compile a linux version plugin on my mac-os?

This should be easy if you have docker installed! The below is how we build the linux release binary on Mac:

  1. Build the docker images:

    docker-compose build prereqs protoc-plugin

  2. Copy the protoc binary to local dir:

    docker cp $(docker create grpcweb/protoc-plugin):/github/grpc-web/javascript/net/grpc/web/generator/protoc-gen-grpc-web ./protoc-gen-grpc-web

Hope that helps! :)