Filtering: filter field name
This rule enforces that the field used for filtering is called filter
and not filters
, as mandated by AIP-160.
Details
This rule looks at the request message for List methods and custom
methods to ensure that there is no field, string filters
. If there is,
the rule is violated and suggests that the field be, string filter
.
Examples
Incorrect code for this rule:
// Incorrect.
rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {
string filters = 1;
}
// Incorrect.
rpc CheckoutBook(CheckoutBookRequest) returns (CheckoutBookResponse) {
string filters = 1;
}
Correct code for this rule:
// Correct.
rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {
string filter = 1;
}
// Correct.
rpc CheckoutBook(CheckoutBookRequest) returns (CheckoutBookResponse) {
string filter = 1;
}
Disabling
If you need to violate this rule, use a leading comment above the method. Remember to also include an aip.dev/not-precedent comment explaining why.
// (-- api-linter: core::0160::filter-field-name=disabled
// aip.dev/not-precedent: We need to do this because reasons. --)
rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {
string filters = 1;
}
If you need to violate this rule for an entire file, place the comment at the top of the file.