github.com/googleapis/api-linter@v1.65.2/docs/rules/0146/any.md (about) 1 --- 2 rule: 3 aip: 146 4 name: [core, '0146', any] 5 summary: Avoid `google.protobuf.Any` fields. 6 permalink: /146/any 7 redirect_from: 8 - /0146/any 9 --- 10 11 # Any 12 13 This rule discourages the use of `google.protobuf.Any`, as described in 14 [AIP-146][]. 15 16 ## Details 17 18 This rule complains if it sees a `google.protobuf.Any` field. Common packages 19 (such as `google.api` or `google.longrunning`) are excluded. 20 21 ## Examples 22 23 **Incorrect** code for this rule: 24 25 ```proto 26 // Incorrect. 27 message Book { 28 // google.protobuf.Any is discouraged. 29 google.protobuf.Any contents = 1; 30 } 31 ``` 32 33 **Correct** code for this rule: 34 35 The correct code is likely to vary substantially by use case. See [AIP-146][] 36 for details and tradeoffs of various approaches for generic fields. 37 38 ## Disabling 39 40 If you need to violate this rule, use a leading comment above the method. 41 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 42 43 ```proto 44 // (-- api-linter: core::0146::any=disabled 45 // aip.dev/not-precedent: We need to do this because reasons. --) 46 message Book { 47 google.protobuf.Any contents = 1; 48 } 49 ``` 50 51 If you need to violate this rule for an entire file, place the comment at the 52 top of the file. 53 54 [aip-146]: https://aip.dev/146 55 [aip.dev/not-precedent]: https://aip.dev/not-precedent