github.com/googleapis/api-linter@v1.65.2/docs/rules/0122/resource-collection-identifiers.md (about) 1 --- 2 rule: 3 aip: 122 4 name: [core, '0122', resource-collection-identifiers] 5 summary: Resource patterns must use lowerCamelCase for collection identifiers. 6 permalink: /122/resource-collection-identifiers 7 redirect_from: 8 - /0122/resource-collection-identifiers 9 --- 10 11 # Resource pattern collection identifiers 12 13 This rule enforces that messages that have a `google.api.resource` annotation 14 have properly formatted collection identifiers in each `pattern`, as described 15 in [AIP-122][]. 16 17 ## Details 18 19 This rule scans messages with a `google.api.resource` annotation, and validates 20 the format of `pattern` collection identifiers, specifically that they are in 21 lowerCamelCase form and must start with a lowercase letter. 22 23 ## Examples 24 25 **Incorrect** code for this rule: 26 27 ```proto 28 // Incorrect. 29 message Book { 30 option (google.api.resource) = { 31 type: "library.googleapis.com/Book" 32 // Collection identifiers must be lowerCamelCase. 33 pattern: "Publishers/{publisher}/Books/{book}" 34 }; 35 string name = 1; 36 } 37 ``` 38 39 ```proto 40 // Incorrect. 41 message Book { 42 option (google.api.resource) = { 43 type: "library.googleapis.com/Book" 44 // Collection identifiers must begin with a lower-cased letter. 45 pattern: "/publishers/{publisher}/Books/{book}" 46 }; 47 string name = 1; 48 } 49 ``` 50 51 **Correct** code for this rule: 52 53 ```proto 54 // Correct. 55 message Book { 56 option (google.api.resource) = { 57 type: "library.googleapis.com/Book" 58 pattern: "publishers/{publisher}/books/{book}" 59 }; 60 string name = 1; 61 } 62 ``` 63 64 ## Disabling 65 66 If you need to violate this rule, use a leading comment above the message. 67 68 ```proto 69 // (-- api-linter: core::0122::resource-collection-identifiers=disabled 70 // aip.dev/not-precedent: We need to do this because reasons. --) 71 message Book { 72 option (google.api.resource) = { 73 type: "library.googleapis.com/Book" 74 pattern: "Publishers/{publisher}/Books/{book}" 75 }; 76 string name = 1; 77 } 78 ``` 79 80 If you need to violate this rule for an entire file, place the comment at the 81 top of the file. 82 83 [aip-122]: http://aip.dev/122 84 [aip.dev/not-precedent]: https://aip.dev/not-precedent