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