@toumorokoshi's sandbox for aep.dev-related projects.
Also see DESIGN.md
The process is as follows:
- Author your resource definition via proto messages and
google.api
annotations. - Generate the service proto from the resource proto via
aepc
- Generate your service, grpc-gateway, and openapiv2 code from the service proto via
protoc
- Convert the openapiv2 schema to openapiv3 with
swagger-codegen
- Validate the schema with
spectral
- Clone submodules:
git submodule update
(needed for googleapi protos)
Install swagger codegen:
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.43/swagger-codegen-cli-3.0.43.jar -O swagger-codegen-cli.jar
Install the following go tools (needed for protoc):
go install \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
google.golang.org/protobuf/cmd/protoc-gen-go \
google.golang.org/grpc/cmd/protoc-gen-go-grpc
To use the spec validator, install spectral:
npm install -g @stoplight/spectral-cli
See scripts/regenerate-all.sh.
In this design, there is a grpc-gateway that handles the HTTP bindings and OpenAPI specification. So both must be started.
In two different shells:
go run service/*.go
go run gateway/*.go
To ensure the API generated adheres to the AEP specification, A spectral ruleset is provided to validate your API.
If using aepc
, this is generally not required: the generated API will
adhere to the specification. However, this is helpful for HTTP + JSON
APIs authored via other means (e.g. a web framework like Flask).
spectral lint openapi/openapi.json --ruleset aep-spec/spectral-ruleset.yaml