protoc-gen-gin
What is 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.
Features supported
- 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.
How to use
$ go install \
google.golang.org/protobuf/cmd/[email protected] \
google.golang.org/grpc/cmd/[email protected] \
github.com/grpc-ecosystem/grpc-gateway/v2/[email protected] \
github.com/go-woo/[email protected]
$ protoc --proto_path=. \
--proto_path=./third_party \
--go_out=paths=source_relative:. \
--gin_out=paths=source_relative:. \
./example/v1/greeter.proto
Generate OpenAPI v2 specification
$ protoc --proto_path=. \
--proto_path=./third_party \
--openapiv2_out . \
--openapiv2_opt logtostderr=true \
./example/v1/greeter.proto