The API design is guided by the architectural guidelines in the architecture document. The API is located under REST API specification.
We use the Buf tool to generate the REST API specification, leveraging several plugins to streamline the process. These
plugins include go for Go code generation, go-grpc for gRPC services, connect-openapi for OpenAPI v3 specifications with validation constraints,
grpc-gateway for RESTful APIs, and doc for generating documentation.
The implementation of mapping the API back to the gRPC implementation is realized through code generated by the grpc-gateway tool. The process involves the following steps:
-
Protobuf Definitions:
- The protobuf definitions of the catalog API are located under Catalog Protobuf Spec.
-
Code Generation:
-
The generated code includes the gRPC server and client code.
-
The
grpc-gatewaytool generates code for converting incoming HTTP requests into gRPC requests and sending the responses back to the client. -
Run the following command to generate the necessary code:
make proto-generate
-
This command will generate the gRPC server and client code, the OpenAPI spec, and the REST client.
-
The generated code is located in the API Generated Code directory.
-
-
Manual Linking:
- The linking between the gRPC method calls and the database calls is not autogenerated and has to be updated manually.