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