Use google.api.field_behavior with protoc-gen-ts_proto

39 Views Asked by At

I want to use google.api.field_behavior like this:

message PersonRequest {
  string query = 1 [(google.api.field_behavior) = REQUIRED];
  int32 page_number = 2;
  int32 results_per_page = 3;
  string name3 = 4 [(google.api.field_behavior) = OPTIONAL];
}

I expect the output for name3 to be name3?: string but instead the generated TS is:

export interface PersonRequest {
  query: string;
  pageNumber: number;
  resultsPerPage: number;
  name3: string;
}

I compile the proto file as:

protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto \
    -I. \
    --ts_proto_out=./src \
    ./proto/person.proto

and inclue the googleapi as:

import "proto/googleapis/google/api/field_behavior.proto";
0

There are 0 best solutions below