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

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