github.com/googleapis/api-linter@v1.65.2/docs/rules/0123/resource-definition-type-name.md (about) 1 --- 2 rule: 3 aip: 123 4 name: [core, '0123', resource-definition-type-name] 5 summary: Resource type names must be of the form {Service Name}/{Type}. 6 permalink: /123/resource-definition-type-name 7 redirect_from: 8 - /0123/resource-definition-type-name 9 --- 10 11 # Resource type name 12 13 This rule enforces that files that define a resource with the 14 `google.api.resource_definition` annotation have a properly formatted `type`, as 15 described in [AIP-123][]. 16 17 ## Details 18 19 This rule scans files with `google.api.resource_definition` annotations, and 20 validates the format of the `type` field conforms to `{Service Name}/{Type}`. 21 22 ## Examples 23 24 **Incorrect** code for this rule: 25 26 ```proto 27 import "google/api/resource.proto"; 28 29 // Incorrect. 30 option (google.api.resource_definition) = { 31 // Should not have more than one separating '/'. 32 type: "library.googleapis.com/Genre/Mystery/Book" 33 pattern: "publishers/{publisher}/books/{book}" 34 }; 35 ``` 36 37 **Correct** code for this rule: 38 39 ```proto 40 import "google/api/resource.proto"; 41 42 // Correct. 43 option (google.api.resource_definition) = { 44 type: "library.googleapis.com/Book" 45 pattern: "publishers/{publisher}/books/{book}" 46 }; 47 ``` 48 49 ## Disabling 50 51 If you need to violate this rule, use a leading comment above the annotation. 52 53 ```proto 54 import "google/api/resource.proto"; 55 56 // (-- api-linter: core::0123::resource-definition-type-name=disabled 57 // aip.dev/not-precedent: We need to do this because reasons. --) 58 option (google.api.resource_definition) = { 59 type: "library.googleapis.com/Genre/Mystery/Book" 60 pattern: "publishers/{publisher}/books/{book}" 61 }; 62 ``` 63 64 If you need to violate this rule for an entire file, place the comment at the 65 top of the file. 66 67 [aip-123]: http://aip.dev/123 68 [aip.dev/not-precedent]: https://aip.dev/not-precedent