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

REQUIRED annotation and BatchCreate #316

Open
nodirg opened this issue Oct 2, 2019 · 1 comment
Open

REQUIRED annotation and BatchCreate #316

nodirg opened this issue Oct 2, 2019 · 1 comment

Comments

@nodirg
Copy link

nodirg commented Oct 2, 2019

We try to consistently document required fields with REQUIRED annotation and use BatchCreate pattern:

message CreateFooRequest {
  string parent = 1 [ (google.api.field_behavior) = REQUIRED ];
  Foo foo = 2 [ (google.api.field_behavior) = REQUIRED];
}

message BatchCreateFooRequest {
  string parent = 1 [ (google.api.field_behavior) = REQUIRED ];
  repeated CreateFooRequest requests = 2;
}

Here all Foos must be created in the same parent, and we allow clients to omit parent in subrequests. Marking CreateTestRequest.parent as REQUIRED seems to violate the guideline

Fields should not be described as required in order to signify ... A field which is conditionally required in some situations.

What is the recommendation in this case?

@lukesneeringer
Copy link
Contributor

Oh, hmm. This is a weird situation. I think it is fine to mark it as REQUIRED in this case. I will need to figure out how to word a "subrequest exception".

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

2 participants