github.com/googleapis/api-linter@v1.65.2/docs/rules/0233/request-requests-field.md (about)

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