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

How understand ExtensionDesc options and this value without convert to string? #1198

Closed
sshaplygin opened this issue Sep 2, 2020 · 5 comments
Labels

Comments

@sshaplygin
Copy link

sshaplygin commented Sep 2, 2020

Hi, everyone

How understand field options type without convert to string?

Example part of code:

...
 rpc Encode (EncodeRequest) returns (EncodeResponse) {
        option (google.api.http) = {
            post: "/Encode"
            body: "option"
        };
    }
...

message EncodeRequest {
    string str = 1;
    Option option = 2 [(gogoproto.nullable) = false]; // <- this filed option
}

I realized in my code by call FieldDescriptorProto.GetOptions().String() and compare with const nullable string value. Do you have any ways understand to it?

@sshaplygin sshaplygin changed the title How understand field options type without convert to string How understand field options type without convert to string? Sep 2, 2020
@dsnet
Copy link
Member

dsnet commented Sep 3, 2020

I apologize, but I don't understand what this is asking. Can you be more specific about what you trying to do?

Also, it seems like you're using gogoproto.nullable. Perhaps you should be asking this over at https://github.com/gogo/protobuf/issues?

@sshaplygin
Copy link
Author

Can you be more specific about what you trying to do?

@dsnet, Yeap, sure.

In code I am used descriptor from protobuf/proton-gen-go.
Code parsed proto-file(example in upper) and by them generate swagger-file. I wanna get nullable option field, but I don’t know how compare different options between themself. May be you know best way to compare field options between themself than transform field option to string.

I hope, you can understand my problem))

@sshaplygin
Copy link
Author

sshaplygin commented Sep 4, 2020

I find this interesting protosal - #555

i wanna get setted value from ExtensionDesc witch setted into proto-file. How to do it?

As equivalent from proposal example equals Enable GPS

@sshaplygin sshaplygin changed the title How understand field options type without convert to string? How understand ExtensionDesc options and this value without convert to string? Sep 4, 2020
@dsnet
Copy link
Member

dsnet commented Sep 10, 2020

You have have an ExtensionDesc and want to retrieve the value for a field that the extension descriptor represents, you can use proto.GetExtension.

(FYI, we try to keep our issue tracker about actionable issues. Questions like this are best asked on Slack or someone other means where you can more readily get immediate help. Consider joining the #protobuf channel or the Gophers slack workspace: https://gophers.slack.com/?redir=%2Fmessages%2Fgeneral%2F)

@dsnet dsnet added the question label Sep 10, 2020
@sshaplygin
Copy link
Author

Thanks for you, @dsnet

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

No branches or pull requests

2 participants