github.com/googleapis/api-linter@v1.65.2/docs/rules/0231/request-names-reference.md (about) 1 --- 2 rule: 3 aip: 231 4 name: [core, '0231', request-names-reference] 5 summary: | 6 Batch Get requests should annotate the `names` field with `google.api.resource_reference`. 7 permalink: /231/request-names-reference 8 redirect_from: 9 - /0231/request-names-reference 10 --- 11 12 # Batch Get methods: Resource reference 13 14 This rule enforces that all `BatchGet` requests have 15 `google.api.resource_reference` on their `repeated string names` field, as mandated in 16 [AIP-231][]. 17 18 ## Details 19 20 This rule looks at the `names` field of any message matching `BatchGet*Request` and 21 complains if it does not have a `google.api.resource_reference` annotation. 22 23 ## Examples 24 25 **Incorrect** code for this rule: 26 27 ```proto 28 // Incorrect. 29 message BatchGetBooksRequest { 30 string parent = 1 [ 31 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 32 ]; 33 34 // The `google.api.resource_reference` annotation should also be included. 35 repeated string names = 2 [(google.api.field_behavior) = REQUIRED]; 36 } 37 ``` 38 39 **Correct** code for this rule: 40 41 ```proto 42 // Correct. 43 message BatchGetBooksRequest { 44 string parent = 1 [ 45 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 46 ]; 47 48 repeated string names = 2 [ 49 (google.api.field_behavior) = REQUIRED, 50 (google.api.resource_reference).type = "library.googleapis.com/Book" 51 ]; 52 } 53 ``` 54 55 ## Disabling 56 57 If you need to violate this rule, use a leading comment above the field. 58 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 59 60 ```proto 61 message BatchGetBooksRequest { 62 string parent = 1 [ 63 (google.api.resource_reference).child_type = "library.googleapis.com/Book" 64 ]; 65 66 // (-- api-linter: core::0231::request-names-reference=disabled 67 // aip.dev/not-precedent: We need to do this because reasons. --) 68 repeated string names = 2 [(google.api.field_behavior) = REQUIRED]; 69 } 70 ``` 71 72 If you need to violate this rule for an entire file, place the comment at the 73 top of the file. 74 75 [aip-231]: https://aip.dev/231 76 [aip.dev/not-precedent]: https://aip.dev/not-precedent