| rule |
|
|||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| permalink | /132/request-required-fields | |||||||||
| redirect_from |
|
This rule enforces that all List standard methods do not have unexpected
required fields, as mandated in AEP-132.
This rule looks at any message matching List*Request and complains if it
comes across any required fields other than:
string parent(AEP-132)
Incorrect code for this rule:
// Incorrect.
message ListBooksRequest {
// The parent, which owns this collection of books.
// Format: publishers/{publisher}
string parent = 1 [
(aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED,
(aep.api.field_info).resource_reference_child_type = "library.googleapis.com/Book"
];
// Non-standard required field.
int32 page_size = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]
}Correct code for this rule:
// Correct.
message ListBooksRequest {
// The parent, which owns this collection of books.
// Format: publishers/{publisher}
string parent = 1 [
(aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED,
(aep.api.field_info).resource_reference_child_type = "library.googleapis.com/Book"
];
int32 page_size = 2 [(aep.api.field_info).field_behavior = OPTIONAL]
}If you need to violate this rule, use a leading comment above the field. Remember to also include an aep.dev/not-precedent comment explaining why.
message ListBooksRequest {
// The parent, which owns this collection of books.
// Format: publishers/{publisher}
string parent = 1 [
(aep.api.field_behavior) = FIELD_BEHAVIOR_REQUIRED,
(aep.api.field_info).resource_reference_child_type = "library.googleapis.com/Book"
];
// (-- api-linter: core::0132::request-required-fields=disabled
// aep.dev/not-precedent: We really need this field to be required because
// reasons. --)
int32 page_size = 2 [(aep.api.field_info).field_behavior = FIELD_BEHAVIOR_REQUIRED]
}If you need to violate this rule for an entire file, place the comment at the top of the file.