You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The underlying Google protobuf supports additional options, one of which is the emit_defaults flag and including that directly in the encoding call seems to do the trick:
Notably, this won't pose an issue if you're hydrating Twirp objects from the generated JSON given that they'll populate those missing fields as the default anyway (e.g. false in this case), so it's really only a problem if you're viewing/using the raw response.
emit_defaults: true should be used by default. It was false before to be compatible with the Go implementation, but the newer v7.0.0 release uses emit_defaults by default. We also have to include other changes.
Enhanced customization is avoided in Twirp, but if there's a need for it we could use an option on the service constructor. I would think most options are desired on all-or-none of the api methods.
👋
I recently came across some behavior I wasn't expecting where falsey values are omitted from the json. Here's an example illustrating the issue:
The underlying Google protobuf supports additional options, one of which is the
emit_defaults
flag and including that directly in the encoding call seems to do the trick:I'm thinking we can just support additional pass-through options here: https://github.com/twitchtv/twirp-ruby/blob/master/lib/twirp/encoding.rb#L34. From there, I'm not sure of the best place to allow the caller to configure. Maybe in the rack env?
The text was updated successfully, but these errors were encountered: