Skip to content

Commit

Permalink
Merge pull request #10 from commitdev/http-swagger
Browse files Browse the repository at this point in the history
#4 & #8 Generates swagger and http gateway libs
  • Loading branch information
Pritesh-Patel committed Oct 5, 2019
2 parents 4dec895 + fc55cb4 commit d92dcae
Show file tree
Hide file tree
Showing 12 changed files with 562 additions and 29 deletions.
20 changes: 17 additions & 3 deletions example/hello-world-idl/Makefile
@@ -1,11 +1,13 @@
PROTOC_VERSION := 3.9.2
PROTOC_WEB_VERSION := 1.0.6

PROTO_SOURCES := -I /usr/local/include
PROTO_SOURCES += -I .
PROTO_SOURCES += -I ${GOPATH}/src
PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis
PROTO_SOURCES += -I ${GOPATH}/src/github.com/grpc-ecosystem/grpc-gateway

deps-linux: deps-protoc-linux deps-grpc-web-linux
deps-linux: deps-protoc-linux deps-grpc-web-linux deps-go

deps-protoc-linux:
curl -OL https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-linux-x86_64.zip
Expand All @@ -19,9 +21,14 @@ deps-grpc-web-linux:
sudo mv protoc-gen-grpc-web-$(PROTOC_WEB_VERSION)-linux-x86_64 /usr/local/bin/protoc-gen-grpc-web
chmod +x /usr/local/bin/protoc-gen-grpc-web

generate: generate-grpc generate-web
deps-go:
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway
go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger
go get -u github.com/golang/protobuf/protoc-gen-go

generate: generate-grpc generate-web generate-http

generate-grpc:
generate-grpc:
mkdir -p gen/go
protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/health/*.proto
protoc ${PROTO_SOURCES} --go_out=plugins=grpc:./gen/go ./proto/helloworld/*.proto
Expand All @@ -33,4 +40,11 @@ generate-web:
protoc ${PROTO_SOURCES} --grpc-web_out=import_style=typescript,mode=grpcwebtext:gen/web ./proto/helloworld/*.proto
cp -f -rv gen/web/proto/* gen/web
rm -rf gen/web/Proto gen/web/proto
generate-http:
mkdir -p gen/http gen/swagger
protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true:gen/http --swagger_out=logtostderr=true:gen/swagger ./proto/health/*.proto
protoc ${PROTO_SOURCES} --grpc-gateway_out=logtostderr=true:gen/http --swagger_out=logtostderr=true:gen/swagger ./proto/helloworld/*.proto
cp -f -rv gen/http/proto/* gen/http
cp -f -rv gen/swagger/proto/* gen/swagger
rm -rf gen/swagger/proto

40 changes: 24 additions & 16 deletions example/hello-world-idl/gen/go/health/health.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

159 changes: 159 additions & 0 deletions example/hello-world-idl/gen/http/health/health.pb.gw.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d92dcae

Please sign in to comment.