github.com/googleapis/api-linter@v1.65.2/docs/rules/0132/response-unknown-fields.md (about) 1 --- 2 rule: 3 aip: 132 4 name: [core, '0132', response-unknown-fields] 5 summary: List RPCs should not have unexpected fields in the response. 6 permalink: /132/response-unknown-fields 7 redirect_from: 8 - /0132/response-unknown-fields 9 --- 10 11 # List methods: Unknown fields (Response) 12 13 This rule enforces that all `List` standard methods do not have unexpected 14 fields, as mandated in [AIP-132][]. 15 16 ## Details 17 18 This rule looks at any message matching `List*Response` and complains if it 19 comes across any fields other than: 20 21 - The resource. 22 - `int32/int64 total_size` ([AIP-132][]) 23 - `string next_page_token` ([AIP-158][]) 24 - `repeated string unavailable` ([AIP-217][]) 25 26 It only checks field names; it does not validate type correctness or 27 repeated-ness. 28 29 ## Examples 30 31 **Incorrect** code for this rule: 32 33 ```proto 34 // Incorrect. 35 message ListBooksResponse { 36 repeated Book books = 1; 37 string next_page_token = 2; 38 string publisher_id = 3; // Unrecognized field. 39 } 40 ``` 41 42 **Correct** code for this rule: 43 44 ```proto 45 // Correct. 46 message ListBooksResponse { 47 repeated Book books = 1; 48 string next_page_token = 2; 49 } 50 ``` 51 52 ## Disabling 53 54 If you need to violate this rule, use a leading comment above the field. 55 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 56 57 ```proto 58 message ListBooksResponse { 59 repeated Book books = 1; 60 string next_page_token = 2; 61 // (-- api-linter: core::0132::response-unknown-fields=disabled 62 // aip.dev/not-precedent: We really need this field because reasons. --) 63 string publisher_id = 3; 64 } 65 ``` 66 67 If you need to violate this rule for an entire file, place the comment at the 68 top of the file. 69 70 [aip-132]: https://aip.dev/132 71 [aip-135]: https://aip.dev/135 72 [aip-157]: https://aip.dev/157 73 [aip-158]: https://aip.dev/158 74 [aip.dev/not-precedent]: https://aip.dev/not-precedent