github.com/googleapis/api-linter@v1.65.2/docs/rules/0158/response-unary.md (about) 1 --- 2 rule: 3 aip: 158 4 name: [core, '0158', response-unary] 5 summary: Paginated responses must not use streaming. 6 permalink: /158/response-unary 7 redirect_from: 8 - /0158/response-unary 9 --- 10 11 # Paginated methods: Unary responses 12 13 This rule enforces that all paginated methods (`List` and `Search` methods, or 14 methods with pagination fields) use unary responses, as mandated in 15 [AIP-158][]. 16 17 ## Details 18 19 This rule looks at any message matching `List*Response` or `Search*Response`, 20 or any response message that has `next_page_token` field, and complains if the 21 method uses gRPC server streaming (the `stream` keyword). 22 23 ## Examples 24 25 **Incorrect** code for this rule: 26 27 ```proto 28 // Incorrect. 29 // Streaming is prohibited on paginated responses. 30 rpc ListBooks(ListBooksRequest) returns (stream ListBooksResponse) { 31 option (google.api.http) = { 32 get: "/v1/{parent=publishers/*}/books" 33 }; 34 } 35 ``` 36 37 **Correct** code for this rule: 38 39 ```proto 40 // Correct. 41 rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) { 42 option (google.api.http) = { 43 get: "/v1/{parent=publishers/*}/books" 44 }; 45 } 46 ``` 47 48 ## Disabling 49 50 If you need to violate this rule, use a leading comment above the message or 51 above the field. Remember to also include an [aip.dev/not-precedent][] comment 52 explaining why. 53 54 ```proto 55 // (-- api-linter: core::0158::response-unary 56 // aip.dev/not-precedent: We need to do this because reasons. --) 57 rpc ListBooks(ListBooksRequest) returns (stream ListBooksResponse) { 58 option (google.api.http) = { 59 get: "/v1/{parent=publishers/*}/books" 60 }; 61 } 62 ``` 63 64 If you need to violate this rule for an entire file, place the comment at the 65 top of the file. 66 67 [aip-158]: https://aip.dev/158 68 [aip.dev/not-precedent]: https://aip.dev/not-precedent