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

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