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