protoc-gen-grpc-gateway.exe protoc-gen-openapiv2.exe 目录结构 |—— hello_http/ |—— client/ |—— main.go // 客户端 |—— server/ |—— main.go // GRPC服务端 |—— server_http/ |—— main.go // HTTP服务端 |—— proto/ |—— google // googleApi http-proto定义 |——...
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest 生成swagger文件 和生成grpc和grpc-gateway一起执行,或者单独执行 protoc -I ./pb --openapiv2_out ./doc --openapiv2_opt logtostderr=true \ ./pb/product.proto 当然更推荐使用buf工具 version: v1 plugins: - plug...
protoc-gen-grpc-gateway protoc-gen-openapiv2 protoc-gen-go protoc-gen-go-grpc 其中protoc-gen-go用于编译go语言版本的protobuf,protoc-gen-go-grpc用于编译go语言版本的grpc service,这两个工具与上面的介绍中安装的是一样的。protoc-gen-grpc-gateway、protoc-gen-openapiv2两个工具才是真正与grpc-gateway相...
go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-openapiv2 这样,在$GOPATH/bin 目录下就会生成: protoc-gen-go.exe、protoc-gen-go-grpc.exe、 protoc-gen-grpc-gateway.exe、protoc-gen-openapiv2.exe 注意:grpc-ga...
为了能让 gRPC 提供 REST API,我们需要使用grpc-gateway 我们需要使用protoc-gen-openapiv2从 proto 文件,创建 Swagger UI 所需要的文件 请访问如下地址获取完整教程:https://rkdev.info/cnhttps://rkdocs.netlify.app/cn(备用) 先决条件 使用过 GRPC 的用户都应该知道,protocol buffer 文件需要使用相关的命令行...
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = { description: "Use this API to create a new user"; summary: "Create new user"; }; } rpc UpdateUser (UpdateUserRequest) returns (UpdateUserResponse) { option (google.api.http) = { ...
files - name: grpc-gateway out: api/gen opt: - paths=source_relative - grpc_api_configuration=api/v1/gw_mapping.yaml # protoc-gen-openapiv2 needs to be installed, generate swagger config files based on proto files - name: openapiv2 out: api/gen opt: - grpc...
https://github.com/grpc-ecosystem/grpc-gateway/tree/master/protoc-gen-openapiv2 该工具只能生成restful的接口文档 安装: 安装protobuf 从https://github.com/grpc-ecosystem/grpc-gateway/releases下载对应的二进制文件,重命名为protoc-gen-openapiv2, 放到PATH路径下(也可以在go环境下使用go install安装) ...
自动生成swagger:pb除了可以生成HTTP的gateway,还可以生成swagger文件,用于文档生成,使用到的插件为protoc-gen-openapiv2。安装:生成swagger文件。和生成grpc和grpc-gateway一起执行,或者单独执行。当然更推荐使用buf工具。于是便可以得到doc/product.swagger.json文件。可视化展示:product.swagger.json可以...
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest 1. 2.5 安装go-bindata 下载当前最新稳定版本go-bindata, 用于将swagger-ui的源码转为GO代码: go install -a -v github.com/go-bindata/go-bindata/v3/...@latest ...