Skip to content

Commit b5dbdb4

Browse files
committed
[feat]openapiv3
1 parent b8ac2cf commit b5dbdb4

17 files changed

+145
-137
lines changed

Diff for: .gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ bin/
3535
.idea/
3636
*.swp
3737

38-
docs/
38+
docs/*/*
39+
!docs/game-proto/game.openapi.yaml

Diff for: Dockerfile

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
FROM golang:1.20.5 AS builder
1+
FROM golang:1.20-alpine3.18 AS builder
22

33
#ENV GOPROXY=https://goproxy.cn
44
# CGO_ENABLED=1, need check `ldd --version` is same as builder
55
ENV CGO_ENABLED=0
66

7-
# install cinch tool
8-
RUN go install github.com/go-cinch/cinch/cmd/cinch@latest
7+
RUN apk update && apk add --no-cache git make
98

9+
COPY . /src
1010
WORKDIR /src
1111
# download first can use docker build cache if go.mod not change
1212
COPY go.mod go.sum ./
1313
RUN go mod download
14+
RUN go mod verify
15+
1416
COPY . .
1517
RUN make build
1618

17-
FROM ubuntu:22.04
19+
FROM alpine:3.18
1820

19-
RUN apt-get update && \
20-
apt-get install -y --no-install-recommends ca-certificates netbase && \
21-
rm -rf /var/lib/apt/lists/ && \
22-
apt-get autoremove -y && \
23-
apt-get autoclean -y
21+
RUN apk update && apk add --no-cache bash
2422

2523
COPY --from=builder /src/bin /app
26-
COPY --from=builder /go/bin/cinch /go/bin
2724

2825
WORKDIR /app
2926

Diff for: Makefile

+6-9
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ endif
1717
.PHONY: init
1818
# init env
1919
init:
20-
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
21-
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
20+
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.32.0
21+
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.3.0
2222
go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
2323
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest
2424
go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest
25-
go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest
26-
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
27-
go install github.com/envoyproxy/protoc-gen-validate@latest
28-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin
25+
go install github.com/google/gnostic/cmd/[email protected]
26+
go install github.com/envoyproxy/[email protected]
27+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.55.2
2928

3029
.PHONY: config
3130
# generate internal proto
@@ -55,9 +54,7 @@ api:
5554
--go-http_out=. \
5655
--go-grpc_out=. \
5756
--validate_out=lang=go:. \
58-
--openapiv2_out docs \
59-
--openapiv2_opt logtostderr=true \
60-
--openapiv2_opt json_names_for_fields=false \
57+
--openapi_out=fq_schema_naming=true,default_response=false,output_mode=source_relative:docs \
6158
$$NAME; \
6259
done
6360
@echo 'You can import *.json into https://editor.swagger.io/'

Diff for: api/auth/auth.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: api/auth/auth_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: api/auth/auth_http.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: api/game/game.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: api/game/game_grpc.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: api/game/game_http.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: api/reason/reason.pb.go

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: configs/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
server:
2+
prod: false
23
machineId: ''
34
http:
45
addr: 0.0.0.0:8080

Diff for: internal/biz/reason.go

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package biz
22

33
import (
44
"context"
5+
56
"github.com/go-cinch/common/constant"
67
"github.com/go-cinch/common/middleware/i18n"
78
"github.com/go-cinch/layout/api/reason"

Diff for: internal/conf/conf.pb.go

+110-101
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: internal/conf/conf.proto

+9-8
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ message Server {
2626
string addr = 2;
2727
google.protobuf.Duration timeout = 3;
2828
}
29-
string machineId = 1;
30-
HTTP http = 2;
31-
GRPC grpc = 3;
32-
string language = 4;
33-
bool idempotent = 5;
34-
bool validate = 6;
35-
bool nocache = 7;
36-
string logLevel = 8;
29+
bool prod = 1;
30+
string machineId = 2;
31+
HTTP http = 3;
32+
GRPC grpc = 4;
33+
string language = 5;
34+
bool idempotent = 6;
35+
bool validate = 7;
36+
bool nocache = 8;
37+
string logLevel = 9;
3738
}
3839

3940
message Data {

Diff for: internal/data/client.go

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/go-cinch/common/log"
99
"github.com/go-cinch/layout/api/auth"
1010
"github.com/go-cinch/layout/internal/conf"
11+
"github.com/go-kratos/kratos/v2/middleware/circuitbreaker"
1112
"github.com/go-kratos/kratos/v2/middleware/metadata"
1213
"github.com/go-kratos/kratos/v2/middleware/recovery"
1314
"github.com/go-kratos/kratos/v2/middleware/tracing"
@@ -33,6 +34,7 @@ func NewClient[T any](name, endpoint string, health bool, timeout time.Duration,
3334
grpc.WithMiddleware(
3435
tracing.Client(),
3536
metadata.Client(),
37+
circuitbreaker.Client(),
3638
recovery.Recovery(),
3739
),
3840
grpc.WithOptions(g.WithDisableHealthCheck()),

Diff for: third_party/openapi/v3/openapi.proto renamed to third_party/openapiv3/OpenAPIv3.proto

-1
Original file line numberDiff line numberDiff line change
@@ -669,4 +669,3 @@ message Xml {
669669
bool wrapped = 5;
670670
repeated NamedAny specification_extension = 6;
671671
}
672-
File renamed without changes.

0 commit comments

Comments
 (0)