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

     1  ---
     2  rule:
     3    aip: 133
     4    name: [core, '0133', request-resource-behavior]
     5    summary: |
     6      Create RPCs should annotate the resource field with `google.api.field_behavior`.
     7  permalink: /133/request-resource-behavior
     8  redirect_from:
     9    - /0133/request-resource-behavior
    10  ---
    11  
    12  # Create methods: Field behavior
    13  
    14  This rule enforces that all `Create` standard methods have
    15  `google.api.field_behavior` set to `REQUIRED` on the field representing the
    16  resource, as mandated in [AIP-133][].
    17  
    18  ## Details
    19  
    20  This rule looks at any message matching `Create*Request` and complains if the
    21  resource 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 CreateBooksRequest {
    31    string parent = 1 [
    32      (google.api.field_behavior) = REQUIRED,
    33      (google.api.resource_reference).type = "library.googleapis.com/Publisher"
    34    ];
    35    Book book = 2;  // Should also have (google.api.field_behavior) = REQUIRED.
    36  }
    37  ```
    38  
    39  **Correct** code for this rule:
    40  
    41  ```proto
    42  // Correct.
    43  message CreateBooksRequest {
    44    string parent = 1 [
    45      (google.api.field_behavior) = REQUIRED,
    46      (google.api.resource_reference).type = "library.googleapis.com/Publisher"
    47    ];
    48    Book book = 2 [(google.api.field_behavior) = REQUIRED];
    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 CreateBooksRequest {
    59    string parent = 1 [
    60      (google.api.field_behavior) = REQUIRED,
    61      (google.api.resource_reference).type = "library.googleapis.com/Publisher"
    62    ];
    63  
    64    // (-- api-linter: core::0133::request-resource-behavior=disabled
    65    //     aip.dev/not-precedent: We need to do this because reasons. --)
    66    Book book = 2;
    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