Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whether I can get the structure of the request parameters and response parameters of the grpc interface, this is very useful to me #425

Open
l54808821 opened this issue Oct 26, 2023 · 5 comments

Comments

@l54808821
Copy link

Whether I can get the structure of the request parameters and response parameters of the grpc interface, this is very useful to me

@l54808821
Copy link
Author

image What I get now is only a simple description, which does not satisfy me

@jhump
Copy link
Contributor

jhump commented Oct 26, 2023

@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.

@l54808821
Copy link
Author

l54808821 commented Nov 2, 2023

@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
image
image

@jhump
Copy link
Contributor

jhump commented Nov 7, 2023

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?

@l54808821
Copy link
Author

@jhump I made a web tool that needed to get a preset request body based on the grpc interface, so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants