Skip to content

Commit 5cabc93

Browse files
authored
Rename & Add OpenAPI Specification Generator (#107)
* rename npm name to wechaty-grpc (#106) * add grpc http annotations (wip) * add grpc gateway image * add swagger info annotation * make payload dirty restful * fix name * add more restful endpoint definitions * fix streaming methods * better protoc tools installer script * clean openapi scripts * rename src/index -> src/mod * generate proto js files with annotation * 0.19.1
1 parent 56c24b9 commit 5cabc93

File tree

21 files changed

+496
-164
lines changed

21 files changed

+496
-164
lines changed

.github/workflows/node.js.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Install Dependencies
3939
run: |
4040
npm install
41-
npm run install:lint:protoc
41+
npm run install:protoc
4242
4343
- name: Generate gRPC Stubs
4444
run: npm run generate

.github/workflows/npm.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
- name: Install Dependencies
2525
run: |
2626
npm install
27-
npm run install:lint:protoc
27+
npm run install:protoc
2828
2929
- name: Generate gRPC Stubs
3030
run: npm run generate

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,4 @@ csharp/Wechaty.Grpc/bin/
9494
csharp/Wechaty.Grpc/nupkg/package/
9595
csharp/Wechaty.Grpc/Properties
9696

97+
third-party/

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,12 @@ protoc \
149149

150150
> <https://github.com/improbable-eng/ts-protoc-gen>
151151

152+
## OpenAPI
153+
154+
![gRPC Gateway](docs/images/grpc-gateway-architecture.svg)
155+
156+
> Image credit: [grpc-gateway](https://grpc-ecosystem.github.io/grpc-gateway/)
157+
152158
## RESOURCES
153159

154160
### Documentation

docs/images/grpc-gateway-architecture.svg

Lines changed: 1 addition & 0 deletions
Loading

examples/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
EventResponse,
1414
ContactAliasRequest,
1515
// EventType,
16-
} from '../src/'
16+
} from '../src/mod'
1717
import { StringValue } from 'google-protobuf/google/protobuf/wrappers_pb'
1818

1919
/**

examples/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
EventType,
1010
DingResponse,
1111
EventRequest,
12-
} from '../src/index'
12+
} from '../src/mod'
1313

1414
// import { StringValue } from 'google-protobuf/google/protobuf/wrappers_pb'
1515

openapi/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
gen/
21
gateway
32
go.sum

openapi/Makefile

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,45 @@
1-
PROTOC=protoc \
1+
GENERATED_DIR:="${CURDIR}/../generated/"
2+
THIRD_PARTY_DIR:="${CURDIR}/../third-party/"
3+
4+
PROTOC:=protoc \
25
-I ../proto/ \
36
-I ../proto/wechaty/ \
7+
-I ${THIRD_PARTY_DIR} \
48
../proto/wechaty/puppet.proto \
59

610
.PHONY: all
7-
all: clean generate reverse_proxy_server
11+
all: generate
12+
13+
.PHONY: generate
14+
generate:
15+
${PROTOC} \
16+
--openapiv2_out ${GENERATED_DIR} \
17+
--openapiv2_opt logtostderr=true \
18+
--openapiv2_opt generate_unbound_methods=true \
819

920
.PHONY: clean
1021
clean:
11-
rm -fr gen/*
22+
rm -fr ${GENERATED_DIR}/*
1223

1324
.PHONY: install
1425
install:
15-
[ -d gen ] || mkdir gen
1626
go install \
1727
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway \
1828
github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2 \
1929
google.golang.org/protobuf/cmd/protoc-gen-go \
2030
google.golang.org/grpc/cmd/protoc-gen-go-grpc
2131
go mod tidy
2232

23-
.PHONY: generate
24-
generate: gen_protobuf gen_gateway gen_openapi
25-
2633
.PHONY: gen_protobuf
2734
gen_protobuf:
2835
${PROTOC} \
29-
--go_out ./gen/ --go_opt paths=source_relative \
30-
--go-grpc_out ./gen/ --go-grpc_opt paths=source_relative \
31-
../proto/wechaty/puppet.proto
36+
--go_out ${GENERATED_DIR} --go_opt paths=source_relative \
37+
--go-grpc_out ${GENERATED_DIR} --go-grpc_opt paths=source_relative \
3238

3339
.PHONY: gen_gateway
3440
gen_gateway:
3541
${PROTOC} \
36-
--grpc-gateway_out ./gen/ \
42+
--grpc-gateway_out ${GENERATED_DIR} \
3743
--grpc-gateway_opt logtostderr=true \
3844
--grpc-gateway_opt paths=source_relative \
3945
--grpc-gateway_opt generate_unbound_methods=true \
40-
41-
.PHONY: gen_openapi
42-
gen_openapi:
43-
${PROTOC} \
44-
--openapiv2_out ./gen/ \
45-
--openapiv2_opt logtostderr=true \
46-

openapi/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
# GO gRPC Gateway
12

2-
gRPC Gateway: <https://github.com/grpc-ecosystem/grpc-gateway>
3+
- gRPC Gateway: <https://github.com/grpc-ecosystem/grpc-gateway>
4+
- Template: <https://github.com/johanbrandhorst/grpc-gateway-boilerplate>

0 commit comments

Comments
 (0)