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

Option to specify WellKnownType at field level #738

Open
martindam opened this issue Oct 21, 2021 · 0 comments
Open

Option to specify WellKnownType at field level #738

martindam opened this issue Oct 21, 2021 · 0 comments

Comments

@martindam
Copy link

Protobuf supports a set of well known types (StringValue, Int64Value, ...) to support having optional primitive fields. When these fields are serialized to JSON, the wrapper message is skipped and the value is serialized directly.

I have been using this approach for other types as well, e.g. a URL type, a UUID type, and so on. It would be great if my own custom "wrapped" types could be JSON serialized in the same way well known types are serialized.

To support this, I am proposing to add an option to specify the WellKnownType of a message. When this option is set, the code generator will add the XXX_WellKnownType() string method to the type. The message will be required to have a single field named "value" with id 1.

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

1 participant