github.com/googleapis/api-linter@v1.65.2/docs/rules/0148/use-uid.md (about)

     1  ---
     2  rule:
     3    aip: 148
     4    name: [core, '0148', use-uid]
     5    summary: Use uid instead of id in resource messages.
     6  permalink: /148/use-uid
     7  redirect_from:
     8    - /0148/use-uid
     9  ---
    10  
    11  # Use `uid` as the resource ID field
    12  
    13  This rule encourages the use of `uid` instead of `id` for resource messages, as
    14  mandated in [AIP-148][].
    15  
    16  ## Details
    17  
    18  This rule looks on resource messages for a field named `id`, complains if it
    19  finds it, and suggests the use of `uid` instead.
    20  
    21  ## Examples
    22  
    23  **Incorrect** code for this rule:
    24  
    25  ```proto
    26  // Incorrect.
    27  message Book {
    28    option (google.api.resource) = {
    29      type: "library.googleapis.com/Book"
    30      pattern: "books/{book}"
    31    };
    32  
    33    string name = 1;
    34    string id = 2; // Should be `uid`
    35  }
    36  ```
    37  
    38  **Correct** code for this rule:
    39  
    40  ```proto
    41  // Correct.
    42  message Book {
    43    option (google.api.resource) = {
    44      type: "library.googleapis.com/Book"
    45      pattern: "books/{book}"
    46    };
    47  
    48    string name = 1;
    49    string uid = 2;
    50  }
    51  ```
    52  
    53  ## Disabling
    54  
    55  If you need to violate this rule, use a leading comment above the field or its
    56  enclosing message. Remember to also include an [aip.dev/not-precedent][]
    57  comment explaining why.
    58  
    59  ```proto
    60  // (-- api-linter: core::0148::use-uid=disabled
    61  //     aip.dev/not-precedent: We need to do this because reasons. --)
    62  message Book {
    63    option (google.api.resource) = {
    64      type: "library.googleapis.com/Book"
    65      pattern: "books/{book}"
    66    };
    67  
    68    string name = 1;
    69    string id = 2;
    70  }
    71  ```
    72  
    73  If you need to violate this rule for an entire file, place the comment at the
    74  top of the file.
    75  
    76  [aip-148]: https://aip.dev/148
    77  [aip.dev/not-precedent]: https://aip.dev/not-precedent