github.com/googleapis/api-linter@v1.65.2/docs/rules/0158/response-repeated-first-field.md (about) 1 --- 2 rule: 3 aip: 158 4 name: [core, '0158', response-repeated-first-field] 5 summary: | 6 First field (by both position and field number) of Paginated RPCs' response 7 should be repeated. 8 permalink: /158/response-repeated-first-field 9 redirect_from: 10 - /0158/response-repeated-first-field 11 --- 12 13 # Paginated methods: Page token field 14 15 This rule enforces that all `List` and `Search` methods have a repeatable field 16 as a first field in the response message, as mandated in [AIP-158][]. 17 18 ## Details 19 20 This rule looks at any message matching `List*Response` or `Search*Response` 21 that has `next_page_token` field and complains if the first field (by both 22 position and field number) is not repeated. 23 24 ## Examples 25 26 **Incorrect** code for this rule: 27 28 ```proto 29 // Incorrect. 30 message ListBooksResponse { 31 Book books = 1; // Field should be repeated. 32 string next_page_token = 2; 33 } 34 ``` 35 36 **Correct** code for this rule: 37 38 ```proto 39 // Correct. 40 message ListBooksResponse { 41 repeated Book books = 1; 42 string next_page_token = 2; 43 } 44 ``` 45 46 ## Disabling 47 48 If you need to violate this rule, use a leading comment above the message or 49 above the field. Remember to also include an [aip.dev/not-precedent][] comment 50 explaining why. 51 52 ```proto 53 // (-- api-linter: core::0158::response-repeated-first-field=disabled 54 // aip.dev/not-precedent: We need to do this because reasons. --) 55 message ListBooksResponse { 56 Book books = 1; 57 string next_page_token = 2; 58 } 59 ``` 60 61 If you need to violate this rule for an entire file, place the comment at the 62 top of the file. 63 64 [aip-158]: https://aip.dev/158 65 [aip.dev/not-precedent]: https://aip.dev/not-precedent