github.com/googleapis/api-linter@v1.65.2/docs/rules/4232/required-fields.md (about) 1 --- 2 rule: 3 aip: 4232 4 name: [client-libraries, '4232', required-fields] 5 summary: Method Signatures must contain all fields annotated as required. 6 permalink: /4232/required-fields 7 --- 8 9 # Method Signature: Required fields 10 11 This rule enforces that all `google.api.method_signature` annotations contain 12 all top-level request message fields that are annotated with `REQUIRED`, as 13 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 request field annotated with `REQUIRED` is 19 missing. 20 21 ## Examples 22 23 **Incorrect** code for this rule: 24 25 ```proto 26 // Incorrect. 27 rpc BatchDeleteBooks(BatchDeleteBooksRequest) returns (google.protobuf.Empty) { 28 option (google.api.http) = { 29 post: "/v1/{parent=publishers/*}/books:batchDelete" 30 body: "*" 31 }; 32 // The field "names" is annotated with REQUIRED and is missing from the 33 // method_signature. 34 option (google.api.method_signature) = "parent"; 35 } 36 ``` 37 38 **Correct** code for this rule: 39 40 ```proto 41 // Correct. 42 rpc BatchDeleteBooks(BatchDeleteBooksRequest) returns (google.protobuf.Empty) { 43 option (google.api.http) = { 44 post: "/v1/{parent=publishers/*}/books:batchDelete" 45 body: "*" 46 }; 47 option (google.api.method_signature) = "parent,names"; 48 } 49 ``` 50 51 ## Disabling 52 53 If you need to violate this rule, use a leading comment above the method. 54 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 55 56 ```proto 57 // (-- api-linter: client-libraries::4232::required-fields=disabled 58 // aip.dev/not-precedent: We need to do this because reasons. --) 59 rpc BatchDeleteBooks(BatchDeleteBooksRequest) returns (google.protobuf.Empty) { 60 option (google.api.http) = { 61 post: "/v1/{parent=publishers/*}/books:batchDelete" 62 body: "*" 63 }; 64 option (google.api.method_signature) = "parent"; 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-4232]: https://aip.dev/4232 72 [aip.dev/not-precedent]: https://aip.dev/not-precedent