Skip to content

Conversation

tobiaskohlbau
Copy link
Contributor

@tobiaskohlbau tobiaskohlbau commented Oct 23, 2018

The package jsonpb which is used to un/marshal json values
into protobuf structures has the option to emit default values
within generated json structures. This CL adds support for
this feature by adding emit_json_defaults as command line flag.
Use for e.g. with --twirp_out=emit_json_defaults=ENABLE:..
Notice that once a value is set this feature is turned on. To
disable it just omit emit_json_defaults like for e.g.
--twirp_out=..

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@larrymyers
Copy link
Contributor

Looks like this would provide a way forward for my request in #103.

@taoso
Copy link

taoso commented Dec 16, 2018

👍 I need these feature as well. However, as the twirp does not use go mod, I think @tobiaskohlbau should remove the go.mod and go.sum to make this PR accepted.

@taoso
Copy link

taoso commented Dec 16, 2018

any maintainer is here?

@pkieltyka
Copy link

pretty key feature. 0 is a real value. thank you for adding this to the generator

@tobiaskohlbau tobiaskohlbau force-pushed the feature/addEmitJSONDefaults branch 2 times, most recently from 94d8960 to 3d0f809 Compare December 21, 2018 08:02
The package jsonpb which is used to un/marshal json values
into protobuf structures has the option to emit default values
within generated json structures. This CL adds support for
this feature by adding emit_json_defaults as command line flag.
Use for e.g. with `--twirp_out=emit_json_defaults=ENABLE:.`.
Notice that once a value is set this feature is turned on. To
disable it just omit `emit_json_defaults` like for e.g.
`--twirp_out=.`.

Signed-off-by: Tobias Kohlbau <t.kohlbau@myopenfactory.com>
@tobiaskohlbau tobiaskohlbau force-pushed the feature/addEmitJSONDefaults branch from 3d0f809 to 220d134 Compare December 21, 2018 08:02
@tobiaskohlbau
Copy link
Contributor Author

@lvht thanks for pointing out the accidental added go modules files, I've removed them and rebased the commit.

Hope some maintainer has a point in the future if this could be merged or not.

@marioizquierdo
Copy link
Contributor

Unfortunately, this will have to stay in a branch for now. But there may be a possibility of adding this feature to a major new release (e.g. version 6 or 7). This may potentially break things, but it may be useful.

Lets keep the discussion in the issue #103. I added a long comment exploring different points of view: #103 (comment)

@dpolansky
Copy link
Contributor

Closing this for now. See the discussion in #103 for more context.

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

Successfully merging this pull request may close these issues.

6 participants