This commit is contained in:
72
node_modules/protocol-buffers-schema/test/fixtures/option.proto
generated
vendored
Normal file
72
node_modules/protocol-buffers-schema/test/fixtures/option.proto
generated
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
import "google/protobuf/descriptor.proto";
|
||||
|
||||
extend google.protobuf.FileOptions {
|
||||
optional string my_file_option = 50000;
|
||||
}
|
||||
extend google.protobuf.MessageOptions {
|
||||
optional int32 my_message_option = 50001;
|
||||
}
|
||||
extend google.protobuf.FieldOptions {
|
||||
optional float my_field_option = 50002;
|
||||
}
|
||||
extend google.protobuf.EnumOptions {
|
||||
optional bool my_enum_option = 50003;
|
||||
}
|
||||
extend google.protobuf.EnumValueOptions {
|
||||
optional uint32 my_enum_value_option = 50004;
|
||||
}
|
||||
extend google.protobuf.ServiceOptions {
|
||||
optional MyEnum my_service_option = 50005;
|
||||
}
|
||||
extend google.protobuf.MethodOptions {
|
||||
optional MyMessage my_method_option = 50006;
|
||||
}
|
||||
|
||||
option (my_file_option) = "Hello world!";
|
||||
|
||||
message MyMessage {
|
||||
option (my_message_option) = 1234;
|
||||
|
||||
optional int32 foo = 1 [(my_field_option) = 4.5];
|
||||
optional string bar = 2;
|
||||
}
|
||||
|
||||
enum MyEnum {
|
||||
option (my_enum_option) = true;
|
||||
|
||||
FOO = 1 [(my_enum_value_option) = 321];
|
||||
BAR = 2;
|
||||
}
|
||||
|
||||
message RequestType {}
|
||||
message ResponseType {}
|
||||
|
||||
service MyService {
|
||||
option (my_service_option) = FOO;
|
||||
option (my_service_option_map) = {
|
||||
foo: "bar";
|
||||
};
|
||||
|
||||
rpc MyMethod(RequestType) returns(ResponseType) {
|
||||
// Note: my_method_option has type MyMessage. We can set each field
|
||||
// within it using a separate "option" line.
|
||||
option (my_method_option).foo = 567;
|
||||
option (my_method_option).bar = "Some string";
|
||||
}
|
||||
}
|
||||
|
||||
message FooOptions {
|
||||
optional int32 opt1 = 1;
|
||||
optional string opt2 = 2;
|
||||
}
|
||||
|
||||
extend google.protobuf.FieldOptions {
|
||||
optional FooOptions foo_options = 1234;
|
||||
}
|
||||
|
||||
// usage:
|
||||
message Bar {
|
||||
optional int32 a = 1 [(foo_options).opt1 = 123, (foo_options).opt2 = "baz"];
|
||||
// alternative aggregate syntax (uses TextFormat):
|
||||
optional int32 b = 2 [(foo_options) = { opt1: 123 opt2: "baz" }];
|
||||
}
|
||||
Reference in New Issue
Block a user