@@ -38,3 +38,29 @@ message Book {
3838value and unset most of the time; if an alternative design does not require
3939such a distinction, it is usually preferred. In practice, this means ` optional `
4040** should** only ever be used for integers and floats.
41+
42+ ** Important:** Tracking field presence is * not* the same as documenting API
43+ field behavior as defined in [ AIP-203] [ ] . For example, a field labeled with
44+ ` optional ` for presence tracking ** may** also be annotated as
45+ ` google.api.field_behavior = REQUIRED ` if the field must be set. If you only
46+ want to document the server perceived behavior of a field, read [ AIP-203] [ ] .
47+
48+ ## Rationale
49+
50+ ### field behavior and ` optional `
51+
52+ The field behavior annotation and ` optional ` label are not mutually exclusive,
53+ because they address different problems. The former,
54+ ` google.api.field_behavior ` , focuses on communicating the server's perception of
55+ a field within the API e.g. if it is required or not, if it is immutable, etc.
56+ The latter, proto3's ` optional ` , is a wire format and code generation option
57+ that is strictly for toggling field presence tracking. While it might be
58+ confusing for a field to be simultaneously annotated with
59+ ` google.api.field_behavior = REQUIRED ` and labeled as ` optional ` , they are
60+ unrelated in practice and can reasonably be used together.
61+
62+ ## Changelog
63+
64+ - ** 2023-06-20** : Differentiate from field behavior documentation
65+
66+ [ AIP-203 ] : ./0203.md
0 commit comments