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

     1  ---
     2  rule:
     3    aip: 133
     4    name: [core, '0133', resource-reference-type]
     5    summary: Create should use a `child_type` reference to the created resource.
     6  permalink: /133/resource-reference-type
     7  redirect_from:
     8    - /0133/resource-reference-type
     9  ---
    10  
    11  # Create methods: Parent field resource reference
    12  
    13  This rule enforces that all `Create` standard methods with a `string parent`
    14  field use a proper `google.api.resource_reference`, that being either a
    15  `child_type` referring to the created resource or a `type` referring directly
    16  to the parent 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  `google.api.resource_reference` on the `parent` field refers to the wrong
    22  resource.
    23  
    24  ## Examples
    25  
    26  **Incorrect** code for this rule:
    27  
    28  ```proto
    29  // Incorrect.
    30  message CreateBooksRequest {
    31    // `child_type` should be used instead of `type` when referring to the
    32    // created resource on a parent field.
    33    string parent = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"];
    34    Book book = 2;
    35  }
    36  ```
    37  
    38  **Correct** code for this rule:
    39  
    40  ```proto
    41  // Correct.
    42  message CreateBooksRequest {
    43    string parent = 1 [(google.api.resource_reference).child_type = "library.googleapis.com/Book"];
    44    Book book = 2;
    45  }
    46  ```
    47  
    48  ## Disabling
    49  
    50  If you need to violate this rule, use a leading comment above the field.
    51  Remember to also include an [aip.dev/not-precedent][] comment explaining why.
    52  
    53  ```proto
    54  message CreateBooksRequest {
    55    // (-- api-linter: core::0133::resource-reference-type=disabled
    56    //     aip.dev/not-precedent: We need to do this because reasons. --)
    57    string parent = 1 [(google.api.resource_reference).type = "library.googleapis.com/Book"];
    58    Book book = 2;
    59  }
    60  ```
    61  
    62  If you need to violate this rule for an entire file, place the comment at the
    63  top of the file.
    64  
    65  [aip-133]: https://aip.dev/133
    66  [aip.dev/not-precedent]: https://aip.dev/not-precedent