Skip to content
New issue

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

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

Already on GitHub? # to your account

default enum value is omitted #294

Closed
lingyuan2014 opened this issue Jan 9, 2017 · 1 comment
Closed

default enum value is omitted #294

lingyuan2014 opened this issue Jan 9, 2017 · 1 comment

Comments

@lingyuan2014
Copy link

lingyuan2014 commented Jan 9, 2017

Consider the following IDL

enum MyEnum {
  CASE_A = 0;
  CASE_B = 1;
}
message MyMsg {
  MyEnum my_value = 1;
}

When a MyMsg is sent to an HTTP client (in my case curl) over grpc-gateway with value set to CASE_A (0), the client seem to receive and empty json object with the field my_value omitted all together.
IE, we receive

{}

instead of

{
  "my_value": "CASE_A"
}

In jsonpb, we can set jsonpb.Marshaler.EmitDefaults to true to avoid this behavior. Is that also supported in grpc-gateway?

@tmc
Copy link
Collaborator

tmc commented Jan 10, 2017

This is possible by supplying an option to NewServeMux via https://godoc.org/github.com/grpc-ecosystem/grpc-gateway/runtime#WithMarshalerOption

@tmc tmc closed this as completed Jan 10, 2017
@tamalsaha tamalsaha mentioned this issue Mar 30, 2017
1 task
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants