Skip to content

Instantly share code, notes, and snippets.

@reselbob
Last active June 10, 2022 12:15
Show Gist options
  • Save reselbob/7b87c49e0ac9407b06a96e55ec7ed2f9 to your computer and use it in GitHub Desktop.
Save reselbob/7b87c49e0ac9407b06a96e55ec7ed2f9 to your computer and use it in GitHub Desktop.
simple-grpc-schema
syntax = "proto3";
package simpleapi;
enum Season {
SUMMER = 0;
AUTUMN = 1;
WINTER = 2;
SPRING = 3;
}
enum Level {
LOW = 0;
MEDIUM = 1;
HIGH = 2;
}
message Animal {
string name = 1;
int32 legs = 2;
int32 age = 3;
bool canFly = 4;
}
//defines an Animal Response
message AnimalResponse {
Animal animal = 1;
}
message Flower {
string name = 1;
Season bloomIn = 2;
int32 color = 3;
Level waterNeeds = 4;
}
//defines a Flower Response
message FlowerResponse {
Flower flower = 1;
}
message Car {
string make = 1;
string model = 2;
int32 year = 3;
}
//used to search for cars by year
message CarRequest {
int32 year = 1;
}
//defines cars returned as a single array
message CarResponse {
repeated Car car = 1;
}
service SimpleService {
rpc GetAnimals () returns (stream AnimalResponse) {
}
rpc GetFlowers () returns (stream FlowerResponse) {
}
rpc GetCars (SearchCarRequest) returns (CarResponse) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment