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

Expose presence of explicit optional keyword on fields #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mwatson2
Copy link

@mwatson2 mwatson2 commented May 11, 2022

Whilst all fields in proto3 are optional, in the sense that they can be omitted from the message serialization, the optional keyword still carries a meaning. For fields that are not explicitly marked optional then when the field is missing from a message this is considered equivalent to the field being present with default value. APIs need not distinguish these two cases. When fields are explicitly marked optional (or if they are in a oneof) then the field missing case is a separate case from present-with-default-value case.

It would therefore be useful to expose whether a field is explicitly marked as optional in the parsed data structure.

This PR adds a property optional in the field structure that, if present and true, indicates that the field was marked explicitly as optional, or inside a oneof.

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.

1 participant