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