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

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