Why grpc-gateway generate string fields instead of int or float?

2.1k views Asked by At

Everyone hello

When I try generate protobuf with different fields in the message, it somehow generates string fields in the documentation instead of int or float

I'll attach the protofile code and the structure code.

 service Payment {
     rpc CreateResult(CreateResultRequest) returns(CreateResultResponse){
         option (google.api.http) = {
         post: "/v1/payment/result"
         body: "*"
     };
 }

 message CreateResultRequest {
     string ik_co_id = 1;
     string ik_pw_via = 2;
     string ik_pm_no = 3 ;
     int64 ik_am = 4;
     string ik_cur = 5;
     string ik_desc = 6;
     string ik_sign = 7;
     string ik_co_prs_id = 8;
     string ik_inv_id = 9;
     string ik_inv_st = 10;
     string ik_inv_crt = 11;
     string ik_inv_prc = 12;
     string ik_trn_id = 13;
     int64 ik_co_rfn = 14;
     float ik_ps_price = 15;
 }

enter image description here

enter image description here

1

There are 1 answers

0
Matteo On BEST ANSWER

The int64 filed is mapped as string by design (but should be a number, of course), you can find better details in this comment on github.

So I suggest you to use a different type,

Proto3 to JSON Mapping:
int64, uint64 ---> String
float, double ----> number.