66 lines
1.4 KiB
Protocol Buffer
66 lines
1.4 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package demo;
|
|
|
|
import "google/protobuf/empty.proto";
|
|
import "google/protobuf/timestamp.proto";
|
|
|
|
// Service demo.
|
|
//
|
|
// All leading comments will be copied to markdown.
|
|
service Demo {
|
|
// Rpc demo
|
|
//
|
|
// All leading comments will be copied to markdown.
|
|
rpc Echo1(Foo) returns (google.protobuf.Empty) {}
|
|
// Another rpc demo
|
|
rpc Echo2(google.protobuf.Empty) returns (Foo) {}
|
|
}
|
|
|
|
// Leading comments of message will be ignored.
|
|
message Foo {
|
|
// boolean value demo
|
|
bool a = 1;
|
|
// 32 bit int value demo
|
|
int32 b = 2;
|
|
// 64 bit int value demo
|
|
int64 c = 3; // stored as string
|
|
// float value demo
|
|
double d = 4;
|
|
// string value demo
|
|
string e = 5;
|
|
// bytes value demo
|
|
bytes f = 6; // stored as base64 string
|
|
// message value demo
|
|
Bar g = 7;
|
|
// imported message value demo
|
|
google.protobuf.Timestamp h = 8;
|
|
}
|
|
|
|
message Bar {
|
|
// string list value demo
|
|
repeated string a = 1;
|
|
// map value demo
|
|
map<int32,string> b = 2;
|
|
// self reference value demo
|
|
Baz c = 3;
|
|
enum Sex {
|
|
Unknown = 0;
|
|
Male = 1;
|
|
Female = 2;
|
|
}
|
|
// enum value demo
|
|
Sex d = 4;
|
|
// message list value demo
|
|
repeated Person e = 5;
|
|
}
|
|
|
|
message Baz {
|
|
Bar a = 1; // self-referenced message will be displayed as {}
|
|
}
|
|
|
|
message Person {
|
|
string name = 1;
|
|
int32 age = 2;
|
|
}
|