-
Notifications
You must be signed in to change notification settings - Fork 67
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
Option to force singular field naming (JS generator) #42
Comments
this also just bit us, and makes it hard to use shared protobuf fields with our generated typescript as well: |
I also have this problem. I can't use the generated types in a Typescript client consuming an API from grpc-gateway. grpc-gateway (correctly) sends my repeated field as It's pretty unfriendly to change the field name from the definition. If the goal is to avoid collisions with internal fields, you could do something like the go implementation does and put them all in a weirdly named field like |
Well, instead of just complaining, I wrote a protoc plugin for the grpc-gateway use-case. Maybe it will help someone out. No warranty implied, use at your own risk etc. https://gist.github.com/majelbstoat/5f73f58a057123c8d46db66ebbaae987 |
You could just use https://github.com/thesayyn/protoc-gen-ts. it works well with almost every grpc framework out there. |
That's cool, but it doesn't work with gprc-gateway |
I use both python and JS protocol buffers and the deserialize results are different. it makes it pretty unusable. Why do we even need the "List" suffix in the first place? |
Does anyone have any workarounds or suggestions? |
In the project I'm currently working on, I had to resort to converting the generated client files manually, like so
|
It'll be nice to see the opinion of the developers which maintain the project about this issue. |
Sorry we have no plans to change the naming conventions or adding options to control the naming due to compatibility and maintenance issues, respectively. |
Hey, I just wanted to update this thread as I have just recently dealt with this very issue. There is a forked repository which can be found here that removes the auto addition of "List" when the "repeated" keyword is used in the proto document. After building the binary (protoc-gen-js in this case) from the cloned repository you can run the cmd |
What language does this apply to?
This is for proto3 Javascript code generation.
Describe the problem you are trying to solve.
A repeated field, when generated to javascript, will be appended with a List suffix. This behaviour introduces (forced) changes to the user-defined names which can sometimes be unwanted as we'd (generally) expect the field names to match the original proto file.
Describe the solution you'd like
Field annotation (a boolean) to force singular naming.
Describe alternatives you've considered
Additional context
https://stackoverflow.com/questions/51508553/why-does-the-protobuf-javascript-compiler-suffix-collections-with-list-map
The text was updated successfully, but these errors were encountered: