Skip to content

Commit 2725b9d

Browse files
committed
generate representative proto definitions
1 parent e6c67fd commit 2725b9d

16 files changed

Lines changed: 683 additions & 160 deletions

priv/protos/common_types.proto

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
syntax = "proto3";
2+
3+
package common;
4+
5+
// Common messages to be imported by other proto files
6+
7+
message Address {
8+
string street = 1;
9+
string city = 2;
10+
string state = 3;
11+
string postal_code = 4;
12+
string country = 5;
13+
}
14+
15+
message Coordinates {
16+
double latitude = 1;
17+
double longitude = 2;
18+
double altitude = 3;
19+
}
20+
21+
message Money {
22+
string currency_code = 1;
23+
int64 units = 2;
24+
int32 nanos = 3;
25+
}
26+
27+
enum Priority {
28+
PRIORITY_UNSPECIFIED = 0;
29+
LOW = 1;
30+
MEDIUM = 2;
31+
HIGH = 3;
32+
CRITICAL = 4;
33+
}
34+
35+
message TimeRange {
36+
int64 start_time = 1;
37+
int64 end_time = 2;
38+
}
Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,20 @@
1-
syntax = "proto2";
1+
syntax = "proto3";
22

3-
import "google/protobuf/timestamp.proto";
4-
import "google/protobuf/any.proto";
5-
6-
package testserviceV2;
3+
package custom_prefix;
74

5+
// This proto demonstrates Elixir-specific custom module prefix option
86
import "elixirpb.proto";
9-
option (elixirpb.file).module_prefix = "HLW";
10-
11-
service TestService {
12-
rpc CallFunction (TestRequest) returns (TestReply) {}
13-
}
14-
15-
message TestRequest {
16-
required string name = 1;
17-
optional Enum enum = 2;
18-
oneof test_oneof {
19-
string label = 3;
20-
int32 value = 4;
21-
}
22-
map<string, int32> g = 5;
23-
repeated google.protobuf.Any instrument = 6;
24-
extensions 10 to 20;
25-
}
26-
27-
message Location {
28-
optional double latitude = 1;
29-
optional double longitude = 2;
30-
}
7+
option (elixirpb.file).module_prefix = "CustomPrefix";
318

32-
extend TestRequest {
33-
optional string data = 10;
34-
optional Location location = 11;
9+
// Simple service to test custom module prefix generation
10+
service PrefixService {
11+
rpc Echo (EchoRequest) returns (EchoResponse) {}
3512
}
3613

37-
message TestReply {
38-
required google.protobuf.Timestamp today = 2;
14+
message EchoRequest {
15+
string message = 1;
3916
}
4017

41-
enum Enum {
42-
A = 0;
43-
B = 1;
18+
message EchoResponse {
19+
string reply = 1;
4420
}

priv/protos/edge_cases.proto

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
syntax = "proto3";
2+
3+
package edge_cases;
4+
5+
// Empty service (no methods) - edge case
6+
service EmptyService {
7+
}
8+
9+
// Service with unusual but valid patterns
10+
service EdgeCaseService {
11+
// Method names with underscores and different conventions
12+
rpc process_data (Request) returns (Response) {}
13+
rpc ProcessData (Request) returns (Response) {}
14+
rpc PROCESS_DATA (Request) returns (Response) {}
15+
16+
// Empty request or response
17+
rpc EmptyInput (EmptyMessage) returns (Response) {}
18+
rpc EmptyOutput (Request) returns (EmptyMessage) {}
19+
rpc BothEmpty (EmptyMessage) returns (EmptyMessage) {}
20+
}
21+
22+
message EmptyMessage {
23+
// Intentionally empty message
24+
}
25+
26+
message Request {
27+
string data = 1;
28+
}
29+
30+
message Response {
31+
string result = 1;
32+
}
33+
34+
// Unusual field numbering
35+
message SparseFieldNumbers {
36+
string field_1 = 1;
37+
string field_536870911 = 536870911; // Max field number (2^29 - 1)
38+
}
39+
40+
// Many fields
41+
message ManyFields {
42+
string field_001 = 1;
43+
string field_002 = 2;
44+
string field_003 = 3;
45+
string field_004 = 4;
46+
string field_005 = 5;
47+
string field_006 = 6;
48+
string field_007 = 7;
49+
string field_008 = 8;
50+
string field_009 = 9;
51+
string field_010 = 10;
52+
string field_011 = 11;
53+
string field_012 = 12;
54+
string field_013 = 13;
55+
string field_014 = 14;
56+
string field_015 = 15;
57+
string field_016 = 16;
58+
string field_017 = 17;
59+
string field_018 = 18;
60+
string field_019 = 19;
61+
string field_020 = 20;
62+
}
63+
64+
// Complex enum
65+
enum DetailedStatus {
66+
// Enum with zero value (required in proto3)
67+
DETAILED_STATUS_UNSPECIFIED = 0;
68+
69+
// Various naming patterns
70+
status_active = 1;
71+
STATUS_INACTIVE = 2;
72+
Status_Pending = 3;
73+
74+
// Negative enum values (valid but unusual)
75+
ERROR_STATE = -1;
76+
CRITICAL_ERROR = -100;
77+
78+
// Large enum values
79+
MAX_STATUS = 2147483647; // Max int32
80+
}
81+
82+
// Multiple oneofs in one message
83+
message MultipleOneofs {
84+
oneof first_choice {
85+
string option_a1 = 1;
86+
int32 option_a2 = 2;
87+
}
88+
89+
oneof second_choice {
90+
string option_b1 = 3;
91+
int32 option_b2 = 4;
92+
}
93+
94+
oneof third_choice {
95+
string option_c1 = 5;
96+
int32 option_c2 = 6;
97+
}
98+
99+
string regular_field = 7;
100+
}
101+
102+
// Nested maps
103+
message NestedMaps {
104+
map<string, InnerMap> outer_map = 1;
105+
map<int32, string> int_key_map = 2;
106+
map<int64, int64> numeric_map = 3;
107+
map<bool, string> bool_key_map = 4;
108+
}
109+
110+
message InnerMap {
111+
map<string, string> data = 1;
112+
map<string, int32> counts = 2;
113+
}
114+
115+
// Circular reference patterns (different from recursive_message.proto)
116+
message CircularA {
117+
CircularB b_field = 1;
118+
string data = 2;
119+
}
120+
121+
message CircularB {
122+
CircularC c_field = 1;
123+
string data = 2;
124+
}
125+
126+
message CircularC {
127+
CircularA a_field = 1;
128+
string data = 2;
129+
}
130+
131+
// Reserved with various patterns
132+
message WithReservedFields {
133+
string active_field_1 = 1;
134+
135+
reserved 2, 15, 9 to 11;
136+
reserved "foo", "bar", "old_field";
137+
138+
string active_field_16 = 16;
139+
140+
reserved 100 to max;
141+
}
142+
143+
// Unicode and special characters in comments
144+
message UnicodeTest {
145+
// Field with emoji in comment: 🚀 rocket
146+
string rocket_field = 1;
147+
148+
// Mathematical symbols: ∑ ∫ π
149+
double pi_field = 2;
150+
151+
// Various languages: 你好 مرحبا שלום
152+
string greeting = 3;
153+
}

priv/protos/empty_service.proto

Lines changed: 0 additions & 5 deletions
This file was deleted.

priv/protos/helloworld.proto

Lines changed: 0 additions & 27 deletions
This file was deleted.

priv/protos/imports_test.proto

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
syntax = "proto3";
2+
3+
package imports_test;
4+
5+
// Import from local proto file
6+
import "common_types.proto";
7+
8+
// Import from google protos
9+
import "google/protobuf/timestamp.proto";
10+
11+
// Service demonstrating cross-file type usage
12+
service ImportTestService {
13+
rpc CreateUser (UserRequest) returns (UserResponse) {}
14+
rpc UpdateLocation (LocationUpdate) returns (LocationResponse) {}
15+
}
16+
17+
message UserRequest {
18+
string name = 1;
19+
string email = 2;
20+
21+
// Using imported type from common_types.proto
22+
common.Address address = 3;
23+
common.Coordinates location = 4;
24+
25+
// Using imported google type
26+
google.protobuf.Timestamp registered_at = 5;
27+
}
28+
29+
message UserResponse {
30+
string user_id = 1;
31+
common.Priority priority = 2;
32+
google.protobuf.Timestamp created_at = 3;
33+
34+
// Nested message that uses imported types
35+
message Profile {
36+
common.Address billing_address = 1;
37+
common.Address shipping_address = 2;
38+
repeated common.Coordinates recent_locations = 3;
39+
}
40+
41+
Profile profile = 4;
42+
}
43+
44+
message LocationUpdate {
45+
string user_id = 1;
46+
common.Coordinates new_location = 2;
47+
google.protobuf.Timestamp timestamp = 3;
48+
}
49+
50+
message LocationResponse {
51+
bool success = 1;
52+
common.Coordinates confirmed_location = 2;
53+
54+
// Map using imported types
55+
map<string, common.TimeRange> visit_history = 3;
56+
}
57+
58+
// Message demonstrating repeated imported types
59+
message BulkOperation {
60+
repeated common.Address addresses = 1;
61+
repeated common.Money transactions = 2;
62+
map<string, common.Priority> task_priorities = 3;
63+
}

0 commit comments

Comments
 (0)