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

     1  ---
     2  rule:
     3    aip: 123
     4    name: [core, '0123', resource-reference-type]
     5    summary: Resource reference annotations should only apply to strings.
     6  permalink: /123/resource-reference-type
     7  redirect_from:
     8    - /0123/resource-reference-type
     9  ---
    10  
    11  # Resource annotation presence
    12  
    13  This rule enforces that any field with a `google.api.resource_reference`
    14  annotation has a `string` type, as described in [AIP-123][].
    15  
    16  ## Details
    17  
    18  This rule scans all fields with a `google.api.resource_reference` annotation.
    19  If one is found, the type is checked, and the rule complains if the type is
    20  anything other than `string`.
    21  
    22  It suggests the removal of the annotation rather than fixing the type, because
    23  what we have observed in real life is that the annotation is usually what is
    24  in error rather than the selected type.
    25  
    26  ## Examples
    27  
    28  **Incorrect** code for this rule:
    29  
    30  ```proto
    31  // Incorrect.
    32  message Book {
    33    string name = 1;
    34  
    35    // This is not a resource reference; the annotation does not belong.
    36    Author author = 2 [(google.api.resource_reference) = {
    37      type: "library.googleapis.com/Author"
    38    }];
    39  }
    40  ```
    41  
    42  **Correct** code for this rule:
    43  
    44  ```proto
    45  // Correct.
    46  message Book {
    47    string name = 1;
    48  
    49    Author author = 2;
    50  }
    51  ```
    52  
    53  ```proto
    54  // Correct.
    55  message Book {
    56    string name = 1;
    57  
    58    string author = 2 [(google.api.resource_reference) = {
    59      type: "library.googleapis.com/Author"
    60    }];
    61  }
    62  ```
    63  
    64  ## Disabling
    65  
    66  Do not violate this rule; it will break several tools.
    67  
    68  [aip-123]: https://aip.dev/123