-
Notifications
You must be signed in to change notification settings - Fork 517
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
feat(AIP-203): clarify immutable optional, required fields #1120
feat(AIP-203): clarify immutable optional, required fields #1120
Conversation
Previous guidance had OPTIONAL as a singular value that had to be mutually exclusive with every other annotation. This eliminates the ability to express fine-grained details like OPTIONAL + INPUT_ONLY. In a similar vain, IMMUTABLE does not imply required, nor input. Clarifying which annotations are required based on these update.
removed missed wording on optional.
@@ -171,6 +163,15 @@ A resource with an unordered list **may** return the list in a stable order, or | |||
|
|||
## Rationale | |||
|
|||
### Required set of annotations | |||
|
|||
A field used in a request message must be either an input or an output. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does this mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section explains why some combination of annotations are required, and was trying to explain that a field is either and input or and output, and therefore a full description of the behavior should include at least one of required, optional, or output_only.
@@ -171,6 +163,15 @@ A resource with an unordered list **may** return the list in a stable order, or | |||
|
|||
## Rationale | |||
|
|||
### Required set of annotations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this section should exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you clarify which section, and clarify why you think it shouldn't exist? If you're referring to the rationale section, there was several requests internally and unanimous support among the current API design team. Public discussion is at: #1058.
|
||
In the case of an output, the `OUTPUT_ONLY` annotation is sufficient. | ||
|
||
In the case of an input, a field is either required or optional, and therefore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We specifically didn't want to mandate OPTIONAL. (There was debate on whether to even provide it.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and after a decent amount of discussion it was agreed that field_behavior should be required: #1100. See the rationale section for more details, but this choice has lead to a lot of incorrectly documented fields since developers did not think through the field behavior choice. field behavior is being used as forcing function.
@@ -24,10 +24,12 @@ field behavior, such as a field being required or immutable. | |||
RecognitionAudio audio = 2 [(google.api.field_behavior) = REQUIRED]; | |||
``` | |||
|
|||
- APIs **must** apply the `google.api.field_behavior` annotation on every field. | |||
- APIs **must** apply the `google.api.field_behavior` annotation on every field |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When did this become a requirement? It shouldn't be one. Leaving off a field_behavior
annotation is equivalent to specifying OPTIONAL
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1100, there's a separate thread you opened we could discuss this too.
@@ -142,20 +148,6 @@ Potential use cases for immutable fields (this is not an exhaustive list) are: | |||
**Note:** Fields which are "conditionally immutable" **must not** be given the | |||
immutable annotation. | |||
|
|||
### Optional | |||
|
|||
The use of `OPTIONAL` indicates that a field is not required, nor covered by |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason that "not covered by any of the above descriptions" was included is because when the annotation was being debated, API producers wanted to avoid the outcome of having to specify field_behavior
on every field. We almost didn't provide OPTIONAL
at all, but Docgen wanted it for cases where documentation needed to call out that the field was optional (e.g. if it was counter-intuitive).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, that matches my understanding as well. There's been a lot of discussion internally around this and the conclusion (with ATL review) was that we should require these, as the cost to API producers is worth the benefit to clients.
@lukesneeringer thanks! I really appreciate the time to review. I answered your questions, so hopefully that provides context. Let me know if you have blockers. Regarding the requirement of field_behavior overall, that's a decision we made internally (that this CL is intended to publicize). |
@lukesneeringer gentle ping. Since we have agreement internally to move forward with this, and all current Googlers approve, I'm inclined to merge this. If you think there is a strong technical reason, I'm definitely open to talking those out. |
@toumorokoshi Sure, that's fine. I'm not particularly concerned about whether |
Of course, and I think despite your xoogler status, your opinion is still very valuable. Thank you for taking our time to review! I do really appreciate it. |
Previous guidance had OPTIONAL as a singular value that had to be mutually exclusive with every other annotation. This eliminates the ability to express fine-grained details like OPTIONAL + INPUT_ONLY.
In a similar vain, IMMUTABLE does not imply required, nor input.
Clarifying which annotations are required based on these update.
fixes #1119