protoc-gen-gin

command module
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2022 License: MIT Imports: 15 Imported by: 0

README

What is protoc-gen-gin

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 and can generate OpenAPI v2 document.
  • Enum fields in the path parameter (including repeated enum fields).
  • Optionally emitting API definitions for OpenAPI (Swagger) v2.

How to use

$ 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

Generate OpenAPI v2 specification

$ protoc --proto_path=. \
    --proto_path=./third_party \
    --openapiv2_out . \
    --openapiv2_opt logtostderr=true \
    ./example/v1/greeter.proto

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
v1
third_party

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL