I have generated JavaScript files by compiling proto files with "grpc-web_out" command. These myptoto_pb.js file contains all proto message fields in flatcase (case insensitive). Is there any additional option which I am missing out here? How do I generate js files, with case sensitive camelCase fields? (message fields should be retained as it is)
I have used below command to generate these files:
protoc.exe -I../grpc/proto/ --js_out=import_style=commonjs,binary:../src/grpchandlers/ ../proto/*.proto
protoc.exe -I../grpc/proto/ --grpc-web_out=import_style=commonjs,mode=grpcwebtext:../src/grpchandlers/ ../grpc/proto/*.proto
Here is the sample proto file
//myproto.proto
syntax = "proto3";
option java_multiple_files = true;
option java_package = "com.grpc.messages";
option java_outer_classname = "CommonOuter";
option java_generic_services = true;
package remote;
import "base.proto";
message UserProfileInfo {
int64 userId = 1;
string userEmail = 2;
int64 companyDepartmentId = 3;
}
message UserProfileInfoArray {
repeated UserProfileInfo value = 1;
}
and generated JavaScript code:
//myproto_pb.js
/**
* Static version of the {@see toObject} method.
* @param {boolean|undefined} includeInstance Deprecated. Whether to include
* the JSPB instance for transitional soy proto support:
* http://goto/soy-param-migration
* @param {!proto.remote.UserProfileInfo} msg The msg instance to transform.
* @return {!Object}
* @suppress {unusedLocalVariables} f is only used for nested messages
*/
proto.remote.UserProfileInfo.toObject = function(includeInstance, msg) {
var f, obj = {
userid: jspb.Message.getFieldWithDefault(msg, 1, 0),
useremail: jspb.Message.getFieldWithDefault(msg, 2, ""),
companydepartmentid: jspb.Message.getFieldWithDefault(msg, 3, 0)
};
if (includeInstance) {
obj.$jspbMessageInstance = msg;
}
return obj;
};
Here, userId
in proto is converted to userid
in js code. Same for other fields (userEmail, companyDepartmentId). Generated JavaScript code should have similar camelCase format for all fields.