OpenAPITools / OpenAPITools/openapi-generator
[REQ] Introduce a configuration parameter to conditionally enable/disable validation based on field_behavior constraints, ensuring context-aware checks for Create vs. Update operations.
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
In the current proto specification, AIP-203 defines several google.api.field_behavior options, including required, optional, and output_only. However, it lacks a required in create behavior definition.
According to AIP-133 and AIP-134, the same object (e.g., Book book) should be used for both create and update requests, with the update_mask specifying the fields to be updated in the update interface.
If a field such as book.name is declared as google.api.field_behavior = required the generated openapi.yaml will mark book.name with an asterisk (*) as a required field. While it is expected that book.name is mandatory in the create interface, it becomes problematic when the update interface does not allow modifications to this field but still marks it as required.
Furthermore, the default validation logic in OpenAPI Generator’s protoc-python implementation enforces checks for required fields. This forces clients to include values for such fields (e.g., book.name) even in Update requests where they should be excluded, resulting in usability issues and invalid request construction.
Describe the solution you'd like
Introduce a configuration parameter to conditionally enable/disable validation based on field_behavior constraints, ensuring context-aware checks for Create vs. Update operations.
Describe alternatives you've considered
None
Additional context
proto info
syntax = "proto3";
package book;
import "google/protobuf/field_mask.proto";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
service BookService {
rpc CreateBook(CreateBookRequest) returns (Book) {
option (google.api.http) = {
post: "/v1/test/books/{id}"
body: "book"
};
}
rpc UpdateBook(UpdateBookRequest) returns (Book) {
option (google.api.http) = {
patch: "/v1/test/books/{id}"
body: "book"
};
option (google.api.method_signature) = "book,update_mask";
}
}
message CreateBookRequest {
string id = 1 [(google.api.field_behavior) = REQUIRED];
// The book to create.
Book book = 2 [(google.api.field_behavior) = REQUIRED];
}
message UpdateBookRequest {
string id = 1 [(google.api.field_behavior) = REQUIRED];
Book book = 2 [(google.api.field_behavior) = REQUIRED];
// The list of fields to update.
google.protobuf.FieldMask update_mask = 3[(google.api.field_behavior) = REQUIRED];
}
message Book {
string name = 1 [(google.api.field_behavior) = REQUIRED];
string title = 2;
string author = 3;
int32 rating = 4;
}
Result
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to the protoc-python validation logic and generated openapi.yaml; start there and compare Create and Update requests using the provided Book example. Define the configuration behavior for required field checks by operation, then verify that update requests do not require fields excluded by the update mask.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, python
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100