github.com/googleapis/api-linter@v1.65.2/docs/rules/0231/request-names-behavior.md (about)

     1  ---
     2  rule:
     3    aip: 231
     4    name: [core, '0231', request-names-behavior]
     5    summary: |
     6      Batch Get requests should annotate the `names` field with `google.api.field_behavior`.
     7  permalink: /231/request-names-behavior
     8  redirect_from:
     9    - /0231/request-names-behavior
    10  ---
    11  
    12  # Batch Get methods: Field behavior
    13  
    14  This rule enforces that all `BatchGet` requests have
    15  `google.api.field_behavior` set to `REQUIRED` on their `repeated string names` field, as
    16  mandated in [AIP-231][].
    17  
    18  ## Details
    19  
    20  This rule looks at any message matching `BatchGet*Request` and complains if the
    21  `names` field does not have a `google.api.field_behavior` annotation with a
    22  value of `REQUIRED`.
    23  
    24  ## Examples
    25  
    26  **Incorrect** code for this rule:
    27  
    28  ```proto
    29  // Incorrect.
    30  message BatchGetBooksRequest {
    31    // The `google.api.field_behavior` annotation should also be included.
    32    repeated string names = 1 [(google.api.resource_reference) = {
    33      type: "library.googleapis.com/Book"
    34    }];
    35  }
    36  ```
    37  
    38  **Correct** code for this rule:
    39  
    40  ```proto
    41  // Correct.
    42  message BatchGetBooksRequest {
    43    repeated string names = 1 [
    44      (google.api.field_behavior) = REQUIRED,
    45      (google.api.resource_reference).type = "library.googleapis.com/Book"
    46    ];
    47  }
    48  ```
    49  
    50  ## Disabling
    51  
    52  If you need to violate this rule, use a leading comment above the field.
    53  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    54  
    55  ```proto
    56  message BatchGetBooksRequest {
    57    // (-- api-linter: core::0231::request-names-behavior=disabled
    58    //     aip.dev/not-precedent: We need to do this because reasons. --)
    59    repeated string names = 1 [(google.api.resource_reference) = {
    60      type: "library.googleapis.com/Book"
    61    }];
    62  }
    63  ```
    64  
    65  If you need to violate this rule for an entire file, place the comment at the
    66  top of the file.
    67  
    68  [aip-231]: https://aip.dev/231
    69  [aip.dev/not-precedent]: https://aip.dev/not-precedent