github.com/googleapis/api-linter@v1.65.2/docs/rules/0162/commit-request-name-field.md (about)

     1  ---
     2  rule:
     3    aip: 162
     4    name: [core, '0162', commit-request-name-field]
     5    summary: Commit RPCs must have a `name` field in the request.
     6  permalink: /162/commit-request-name-field
     7  redirect_from:
     8    - /0162/commit-request-name-field
     9  ---
    10  
    11  # Commit requests: Name field
    12  
    13  This rule enforces that all `Commit` methods have a `string name`
    14  field in the request message, as mandated in [AIP-162][].
    15  
    16  ## Details
    17  
    18  This rule looks at any message matching `Commit*Request` and complains if
    19  either the `name` field is missing or it has any type other than `string`.
    20  
    21  ## Examples
    22  
    23  **Incorrect** code for this rule:
    24  
    25  ```proto
    26  // Incorrect.
    27  // Should include a `string name` field.
    28  message CommitBookRequest {
    29  }
    30  ```
    31  
    32  ```proto
    33  // Incorrect.
    34  message CommitBookRequest {
    35    // Field type should be `string`.
    36    bytes name = 1 [
    37      (google.api.field_behavior) = REQUIRED,
    38      (google.api.resource_reference).type = "library.googleapis.com/Book"
    39    ];
    40  }
    41  ```
    42  
    43  **Correct** code for this rule:
    44  
    45  ```proto
    46  // Correct.
    47  message CommitBookRequest {
    48    string name = 1 [
    49      (google.api.field_behavior) = REQUIRED,
    50      (google.api.resource_reference).type = "library.googleapis.com/Book"
    51    ];
    52  }
    53  ```
    54  
    55  ## Disabling
    56  
    57  If you need to violate this rule, use a leading comment above the message (if
    58  the `name` field is missing) or above the field (if it is the wrong type).
    59  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    60  
    61  ```proto
    62  message CommitBookRequest {
    63    // (-- api-linter: core::0162::commit-request-name-field=disabled
    64    //     aip.dev/not-precedent: We need to do this because reasons. --)
    65    bytes name = 1 [
    66      (google.api.field_behavior) = REQUIRED,
    67      (google.api.resource_reference).type = "library.googleapis.com/Book"
    68    ];
    69  }
    70  ```
    71  
    72  If you need to violate this rule for an entire file, place the comment at the
    73  top of the file.
    74  
    75  [aip-162]: https://aip.dev/162
    76  [aip.dev/not-precedent]: https://aip.dev/not-precedent