github.com/googleapis/api-linter@v1.65.2/docs/rules/4232/repeated-fields.md (about) 1 --- 2 rule: 3 aip: 4232 4 name: [client-libraries, '4232', repeated-fields] 5 summary: Method Signatures can only have repeated fields in the last element. 6 permalink: /4232/repeated-fields 7 --- 8 9 # Method Signature: Repeated fields 10 11 This rule enforces that all `google.api.method_signature` annotations do not 12 have `repeated` fields in any position other than the last field of a signature, 13 as mandated in [AIP-4232][]. 14 15 ## Details 16 17 This rule looks at any RPC methods with a `google.api.method_signature` 18 annotation, and complains if any field other than the last is `repeated`. 19 20 ## Examples 21 22 **Incorrect** code for this rule: 23 24 ```proto 25 // Incorrect. 26 rpc BatchDeleteBooks(BatchDeleteBooksRequest) returns (google.protobuf.Empty) { 27 option (google.api.http) = { 28 post: "/v1/{parent=publishers/*}/books:batchDelete" 29 body: "*" 30 }; 31 // The field "names" is repeated and must only come at the end. 32 option (google.api.method_signature) = "names,parent" 33 } 34 ``` 35 36 **Correct** code for this rule: 37 38 ```proto 39 // Correct. 40 rpc BatchDeleteBooks(BatchDeleteBooksRequest) returns (google.protobuf.Empty) { 41 option (google.api.http) = { 42 post: "/v1/{parent=publishers/*}/books:batchDelete" 43 body: "*" 44 }; 45 option (google.api.method_signature) = "parent,names" 46 } 47 ``` 48 49 ## Disabling 50 51 If you need to violate this rule, use a leading comment above the method. 52 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 53 54 ```proto 55 // (-- api-linter: client-libraries::4232::repeated-fields=disabled 56 // aip.dev/not-precedent: We need to do this because reasons. --) 57 rpc BatchDeleteBooks(BatchDeleteBooksRequest) returns (google.protobuf.Empty) { 58 option (google.api.http) = { 59 post: "/v1/{parent=publishers/*}/books:batchDelete" 60 body: "*" 61 }; 62 option (google.api.method_signature) = "names,parent" 63 } 64 ``` 65 66 If you need to violate this rule for an entire file, place the comment at the 67 top of the file. 68 69 [aip-4232]: https://aip.dev/4232 70 [aip.dev/not-precedent]: https://aip.dev/not-precedent