github.com/googleapis/api-linter@v1.65.2/docs/rules/0191/java-outer-classname.md (about) 1 --- 2 rule: 3 aip: 191 4 name: [core, '0191', java-outer-classname] 5 summary: All proto files must set `option java_outer_classname`. 6 permalink: /191/java-outer-classname 7 redirect_from: 8 - /0191/java-outer-classname 9 --- 10 11 # Java outer classname 12 13 This rule enforces that every proto file for a public API surface sets 14 `option java_outer_classname`, as mandated in [AIP-191][]. 15 16 ## Details 17 18 This rule looks at each proto file, and complains if the `java_outer_classname` 19 file annotation is not present, or set to something other than the common class 20 name based on the proto's filename. 21 22 ## Examples 23 24 **Incorrect** code for this rule: 25 26 ```proto 27 // Incorrect. 28 syntax = "proto3"; 29 30 package google.example.v1; 31 32 option java_package = "com.google.example.v1"; 33 option java_multiple_files = true; 34 // Needs `option java_outer_classname = "LibraryProto";` 35 36 message Book {} 37 ``` 38 39 **Correct** code for this rule: 40 41 ```proto 42 // Correct. 43 syntax = "proto3"; 44 45 package google.example.v1; 46 47 option java_package = "com.google.example.v1"; 48 option java_multiple_files = true; 49 option java_outer_classname = "LibraryProto"; 50 51 message Book {} 52 ``` 53 54 ## Disabling 55 56 If you need to violate this rule, use a comment at the top of the file. 57 Remember to also include an [aip.dev/not-precedent][] comment explaining why. 58 59 ```proto 60 // (-- api-linter: core::0191::java-outer-classname=disabled 61 // aip.dev/not-precedent: We need to do this because reasons. --) 62 syntax = "proto3"; 63 64 package google.example.v1; 65 66 option java_package = "com.google.example.v1"; 67 option java_multiple_files = true; 68 69 message Book {} 70 ``` 71 72 [aip-191]: https://aip.dev/191 73 [aip.dev/not-precedent]: https://aip.dev/not-precedent