github.com/googleapis/api-linter@v1.65.2/docs/rules/0132/request-required-fields.md (about)

     1  ---
     2  rule:
     3    aip: 132
     4    name: [core, '0132', request-required-fields]
     5    summary: List RPCs must not have unexpected required fields in the request.
     6  permalink: /132/request-required-fields
     7  redirect_from:
     8    - /0132/request-required-fields
     9  ---
    10  
    11  # List methods: Required fields
    12  
    13  This rule enforces that all `List` standard methods do not have unexpected
    14  required fields, as mandated in [AIP-132][].
    15  
    16  ## Details
    17  
    18  This rule looks at any message matching `List*Request` and complains if it
    19  comes across any required fields other than:
    20  
    21  - `string parent` ([AIP-132][])
    22  
    23  ## Examples
    24  
    25  **Incorrect** code for this rule:
    26  
    27  ```proto
    28  // Incorrect.
    29  message ListBooksRequest {
    30  	// The parent, which owns this collection of books.
    31  	// Format: publishers/{publisher}
    32  	string parent = 1 [
    33  	    (google.api.field_behavior) = REQUIRED,
    34  	    (google.api.resource_reference) = {
    35  	  		child_type: "library.googleapis.com/Book"
    36  	    }];
    37  
    38    // Non-standard required field.
    39    int32 page_size = 2 [(google.api.field_behavior) = REQUIRED]
    40  }
    41  ```
    42  
    43  **Correct** code for this rule:
    44  
    45  ```proto
    46  // Correct.
    47  message ListBooksRequest {
    48  	// The parent, which owns this collection of books.
    49  	// Format: publishers/{publisher}
    50  	string parent = 1 [
    51  	    (google.api.field_behavior) = REQUIRED,
    52  	    (google.api.resource_reference) = {
    53  	  		child_type: "library.googleapis.com/Book"
    54  	    }];
    55  
    56    int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]
    57  }
    58  ```
    59  
    60  ## Disabling
    61  
    62  If you need to violate this rule, use a leading comment above the field.
    63  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    64  
    65  ```proto
    66  message ListBooksRequest {
    67  	// The parent, which owns this collection of books.
    68  	// Format: publishers/{publisher}
    69  	string parent = 1 [
    70  	    (google.api.field_behavior) = REQUIRED,
    71  	    (google.api.resource_reference) = {
    72  	  		child_type: "library.googleapis.com/Book"
    73  	    }];
    74  
    75    // (-- api-linter: core::0132::request-required-fields=disabled
    76    //     aip.dev/not-precedent: We really need this field to be required because
    77    // reasons. --)
    78    int32 page_size = 2 [(google.api.field_behavior) = REQUIRED]
    79  }
    80  ```
    81  
    82  If you need to violate this rule for an entire file, place the comment at the
    83  top of the file.
    84  
    85  [aip-132]: https://aip.dev/132
    86  [aip.dev/not-precedent]: https://aip.dev/not-precedent