github.com/googleapis/api-linter@v1.65.2/docs/rules/0131/request-name-required.md (about) 1 --- 2 rule: 3 aip: 131 4 name: [core, '0131', request-name-required] 5 summary: Get RPCs must have a `name` field in the request. 6 permalink: /131/request-name-required 7 redirect_from: 8 - /0131/request-name-required 9 --- 10 11 # Get methods: Name field 12 13 This rule enforces that all `Get` standard methods have a `string name` field 14 in the request message, as mandated in [AIP-131][]. 15 16 ## Details 17 18 This rule looks at any message matching `Get*Request` and complains if 19 the `name` field is missing. 20 21 ## Examples 22 23 **Incorrect** code for this rule: 24 25 ```proto 26 // Incorrect. 27 message GetBookRequest { 28 string book = 1 [ // Field name should be `name`. 29 (google.api.field_behavior) = REQUIRED, 30 (google.api.resource_reference).type = "library.googleapis.com/Book" 31 ]; 32 } 33 ``` 34 35 **Correct** code for this rule: 36 37 ```proto 38 // Correct. 39 message GetBookRequest { 40 string name = 1 [ 41 (google.api.field_behavior) = REQUIRED, 42 (google.api.resource_reference).type = "library.googleapis.com/Book" 43 ]; 44 } 45 ``` 46 47 ## Disabling 48 49 If you need to violate this rule, use a leading comment above the message. 50 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 51 52 ```proto 53 // (-- api-linter: core::0131::request-name-required=disabled 54 // aip.dev/not-precedent: This is named "book" for historical reasons. --) 55 message GetBookRequest { 56 string book = 1 [ 57 (google.api.field_behavior) = REQUIRED, 58 (google.api.resource_reference).type = "library.googleapis.com/Book" 59 ]; 60 } 61 ``` 62 63 If you need to violate this rule for an entire file, place the comment at the 64 top of the file. 65 66 [aip-131]: https://aip.dev/131 67 [aip.dev/not-precedent]: https://aip.dev/not-precedent