Open l54808821 opened 8 months ago
What I get now is only a simple description, which does not satisfy me
@l54808821, the --protoset-out
flag will save the schema to a file that is a binary encoded google.protobuf.FileDescriptorSet
. That is the typical format of a Protobuf "schema".
This file includes the definitions from the proto source file that defines the elements you are listing or describing as well as all of the files it imports. Other Protobuf runtime APIs that support reflection often have a way to work with these descriptors. In Go, for example, it's various packages under google.golang.org/protobuf/reflection
, with protodesc.NewFiles
being a useful entry point. The general technique is to read in the file contents, unmarshal those bytes into a google.protobuf.FileDescriptorSet
message, and then use these other APIs to turn that message into a more useful type.
@jhump Hello, "fullstorydev/grpcui" project this interface (" http://127.0.0.1:63806/metadata? method=team.Team.add ") return information is what I want, I wonder if it can be obtained by command in this project
I wonder if it can be obtained by command in this project
No, not quite. Most of the logic in this package uses the Go protobuf runtime's reflection facilities: https://pkg.go.dev/google.golang.org/protobuf/reflect
As such, nearly everything works with descriptors (per my earlier reply). Only the browser JS code (which doesn't use a protobuf runtime so doesn't have any way to work with descriptors) uses this representation, for building the HTML form. As such this format is not available outside of the endpoint you highlighted.
What exactly are you trying to do that would make this representation useful?
@jhump I made a web tool that needed to get a preset request body based on the grpc interface, so
Whether I can get the structure of the request parameters and response parameters of the grpc interface, this is very useful to me