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

default enum value is omitted #294

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

default enum value is omitted #294

fiibbb opened this issue Jan 9, 2017 · 1 comment

Comments

@fiibbb
Copy link

fiibbb 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
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