github.com/googleapis/api-linter@v1.65.2/docs/rules/0131/request-name-reference-type.md (about)

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