github.com/googleapis/api-linter@v1.65.2/docs/rules/0140/base64.md (about) 1 --- 2 rule: 3 aip: 140 4 name: [core, '0140', base64] 5 summary: Base64 fields should use the `bytes` type. 6 permalink: /140/base64 7 redirect_from: 8 - /0140/base64 9 --- 10 11 # Base64 fields 12 13 This rule tries to enforce that base64 fields use the `bytes` type, as mandated 14 by [AIP-140][]. 15 16 ## Details 17 18 This rule checks the comments over each field, and if "base64" is mentioned, and yet 19 the field is a `string`, it suggests using `bytes` instead. 20 21 ## Examples 22 23 ### Single word method 24 25 **Incorrect** code for this rule: 26 27 ```proto 28 // Incorrect. 29 message Book { 30 string name = 1; 31 32 // The base64-encoded checksum. 33 string checksum = 2; // Should be bytes. 34 } 35 ``` 36 37 **Correct** code for this rule: 38 39 ```proto 40 // Correct. 41 message Book { 42 string name = 1; 43 44 // The base64-encoded checksum. 45 bytes checksum = 2; 46 } 47 ``` 48 49 ## Disabling 50 51 If you need to violate this rule, use a leading comment above the method. 52 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 53 54 ```proto 55 // (-- api-linter: core::0140::base64=disabled 56 // aip.dev/not-precedent: We need to do this because reasons. --) 57 message Book { 58 string name = 1; 59 60 // The base64-encoded checksum 61 string checksum = 2; 62 } 63 ``` 64 65 If you need to violate this rule for an entire file, place the comment at the 66 top of the file. 67 68 [aip-140]: https://aip.dev/140 69 [aip.dev/not-precedent]: https://aip.dev/not-precedent