The protoc-gen-gin
is a plugin of the Google protocol buffers compiler
protoc.
It reads protobuf service definitions and generates a gin server which
provide more RESTful HTTP API services. This server is generated according to the
google.api.http
annotations in your service definitions.
- Generating JSON API handlers.
- Method parameters in the request body.
- Method parameters in the request path.
- Method parameters in the query string.
- JWT supported.
- Generate OpenAPIv2 with JWT document.
- Multi tenants supported.
- Generate OpenAPIv2 with Multi-tenants document.(soon coming)
- Enum fields in the path parameter.
- Optionally emitting API definitions for OpenAPI (Swagger) v2.
$ go install \
google.golang.org/protobuf/cmd/protoc-gen-go@latest \
google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest \
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest \
github.com/go-woo/protoc-gen-gin@latest
$ protoc --proto_path=. \
--proto_path=./third_party \
--go_out=paths=source_relative:. \
--gin_out=paths=source_relative:. \
./example/v1/greeter.proto
$ protoc --proto_path=. \
--proto_path=./third_party \
--openapiv2_out . \
--openapiv2_opt logtostderr=true \
./example/v1/greeter.proto