Defining the Service
Let’s start with the header.
The proto-definition starts with this:
syntax
=
"proto3"
;
import"google/api/annotations.proto"
;
package sfapi.v1;
optiongo_package
=
"proto"
;
This clearly marks what version of proto we are using (proto3, so all fields are optional
) and prepares the loader for HTTP annotations (used by grpc-gateway, among others) and gives our API a namespace sfapi.v1
.
Nouns
We start with a proto description of or nouns. Here is an example for Film
:
message Film{
stringtitle
=
1;
int32episode_id
=
2;
stringopening_crawl
=
3;
stringdirector
=
4;
stringproducer
=
5;
stringrelease_date
=
6;
repeated stringcharacter_ids
=
7;
// Person.id repeated stringplanet_ids
=
8;
// Planet.id repeated stringstarship_ids
=
9;
// Starship.id repeated stringvehicle_ids
=
10;
// Vehicle.id repeated stringspecies_ids
=
11;
// Species.id stringid
=
12;
}
Verbs
Now, we need our List...