微服务之protobuf生成的ts文件变量命名方式如何定义?
proto文件定义如下:
message LoginResponse {
string access_token = 1;
int32 expires_in = 2;
}
后端gateway这么设置的:
mux := runtime.NewServeMux(runtime.WithMarshalerOption(
runtime.MIMEWildcard,
&runtime.JSONPb{
MarshalOptions: protojson.MarshalOptions{
UseEnumNumbers: true,
UseProtoNames: true,
},
},
))
前端获取到的响应是这样的:
{
"access_token":"xxxx",
"expires_in":7200
}
但是,前端生成的TS文件是这样的:
/** Properties of a LoginResponse. */
interface ILoginResponse {
/** LoginResponse accessToken */
accessToken?: (string|null);
/** LoginResponse expiresIn */
expiresIn?: (number|null);
}
导致在使用范型的情况下无法获取token,感觉应该是生成TS的指令写的有遗漏,查了资料也没弄明白,求大神指教。
AccessToken ExpiresIn 试了吗?,proto 一般都是驼峰命名