1

We have developed grpc services using codefirst protobuf-net method. How can we call these services from javascript using grpc-web? how do we generate grpc javascript client code if we dont have .proto files?

Thanks

last-Programmer
  • 985
  • 3
  • 9
  • 19

1 Answers1

0

Refer to https://protobuf-net.github.io/protobuf-net.Grpc/createProtoFile to convert to your codefirst files to protobuf files. Something like this, using the protobuf-net.Reflection package:

var generator = new SchemaGenerator
{
    ProtoSyntax = ProtoSyntax.Proto3
};

var schema = generator.GetSchema<ICalculator>(); // there is also a non-generic overload that takes Type

using (var writer = new System.IO.StreamWriter("services.proto"))
{
    await writer.WriteAsync(schema);
}
Adrian Mole
  • 49,934
  • 160
  • 51
  • 83