github.com/googleapis/api-linter@v1.65.2/docs/rules/0233/request-unknown-fields.md (about) 1 --- 2 rule: 3 aip: 233 4 name: [core, '0233', request-unknown-fields] 5 summary: Batch Create RPCs should not have unexpected fields in the request. 6 permalink: /233/request-unknown-fields 7 redirect_from: 8 - /0233/request-unknown-fields 9 --- 10 11 # Batch Create methods: Unknown request fields 12 13 This rule enforces that all `BatchCreate` standard methods do not have unexpected 14 fields, as mandated in [AIP-233][]. 15 16 ## Details 17 18 This rule looks at any message matching `BatchCreate*Request` and complains if it comes 19 across any fields other than: 20 21 - `string parent` ([AIP-233][]) 22 - `string request_id` ([AIP-155][]) 23 - `repeated Create*Request requests` ([AIP-233][]) 24 - `bool validate_only` ([AIP-163][]) 25 26 ## Examples 27 28 **Incorrect** code for this rule: 29 30 ```proto 31 // Incorrect. 32 message BatchCreateBooksRequest { 33 string parent = 1 [ 34 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 35 ]; 36 37 repeated CreateBookRequest requests = 2 [ 38 (google.api.field_behavior) = REQUIRED 39 ]; 40 41 string library_id = 3; // Non-standard field. 42 } 43 ``` 44 45 **Correct** code for this rule: 46 47 ```proto 48 // Correct. 49 message BatchCreateBooksRequest { 50 string parent = 1 [ 51 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 52 ]; 53 54 repeated CreateBookRequest requests = 2 [ 55 (google.api.field_behavior) = REQUIRED 56 ]; 57 } 58 ``` 59 60 ## Disabling 61 62 If you need to violate this rule, use a leading comment above the field. 63 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 64 65 ```proto 66 message BatchCreateBooksRequest { 67 string parent = 1 [ 68 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 69 ]; 70 71 repeated CreateBookRequest requests = 2 [ 72 (google.api.field_behavior) = REQUIRED 73 ]; 74 75 // (-- api-linter: core::0233::request-unknown-fields=disabled 76 // aip.dev/not-precedent: We really need this field because reasons. --) 77 string library_id = 3; 78 } 79 ``` 80 81 If you need to violate this rule for an entire file, place the comment at the 82 top of the file. 83 84 [aip-155]: https://aip.dev/155 85 [aip-163]: https://aip.dev/163 86 [aip-233]: https://aip.dev/233 87 [aip.dev/not-precedent]: https://aip.dev/not-precedent