Replies: 2 comments 2 replies
-
What Here are a few slides from a talk I did recently. |
Beta Was this translation helpful? Give feedback.
-
Thanks for the detailed response! I appreciate the snippets, as well as all of your hard work on Wire - it's a fantastic plugin.
Is there a way to work around this in Wire specifically? Say, if we wanted to configure it to assume that all Message-type fields are non-null, is that possible today? If not, how do you and your team(s) typically work around this? We're exploring gRPC and protobuf for newer APIs, and I think a lot of us are finding this limitation in proto3 surprising (having previously assumed that optionality/presence could be properly represented in a protobuf model and built into a generated model accordingly). We can always build checks/assumptions into our network parsing layer to force certain fields as non-null, of course, but hand-checking the optionality of each field on a response seems a bit backwards/negated compared to the idea(s) behind protobuf & code generation. |
Beta Was this translation helpful? Give feedback.
-
I'm new to protobuf & Wire, so I may be misunderstanding the intended use of both.
Currently I'm confused why my Wire-generated Kotlin models have nullable fields even though the protobuf fields aren't marked as
optional
.In the docs, I see that Wire is pretty explicit about nullability:
I think the root cause in my case is that these fields don't use the
required
keyword.I've since learned that
required
was removed from proto3; based on that, my assumption is that every field not marked asoptional
in the protobuf model would be non-null in the Kotlin model (but that doesn't seem to match Wire's default behavior). Why is that?Is this an incorrect way to indicate nullability/presence in a protobuf model? (and if so, what's the alternative recommendation)
Is there a way to configure Wire in a different way to work around this, possibly with a custom
SchemaHandler
?Beta Was this translation helpful? Give feedback.
All reactions