Skip to content

Commit

Permalink
Merge pull request #339 from spacemeshos/v2alpha1-openapi
Browse files Browse the repository at this point in the history
v2alpha1: generate openapi v2 spec
  • Loading branch information
kacpersaw authored Jun 4, 2024
2 parents f5cb15b + 013ee30 commit a632ef5
Show file tree
Hide file tree
Showing 41 changed files with 2,524 additions and 1,111 deletions.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ BUF_VERSION := 1.30.0
GRPC_JSON_PROXY_VERSION := v2.19.1
PROTOC_GO_VERSION := v1.33.0
PROTOC_GEN_GO_VERSION := v1.3.0
GO_SWAGGER_VERSION := v0.31.0

# Everything below this line is meant to be static, i.e. only adjust the above variables. ###

Expand Down Expand Up @@ -54,7 +55,7 @@ endif
export GOBIN := $(BIN_DIR)

BUF := $(BIN_DIR)/buf_$(BUF_VERSION)
$(BUF): protoc-plugins
$(BUF): protoc-plugins deps
@mkdir -p $(BIN_DIR)
@rm -f $(BIN_DIR)/buf_*
@curl -sSL "https://github.com/bufbuild/buf/releases/download/v$(BUF_VERSION)/buf-$(UNAME_OS)-$(UNAME_ARCH)" -o $@
Expand All @@ -66,8 +67,14 @@ protoc-plugins:
@go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@$(GRPC_JSON_PROXY_VERSION)
@go install google.golang.org/protobuf/cmd/protoc-gen-go@$(PROTOC_GO_VERSION)
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@$(PROTOC_GEN_GO_VERSION)
@go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@$(GRPC_JSON_PROXY_VERSION)
.PHONY: protoc-plugins

# Download go deps
.PHONY: deps
deps:
@go install github.com/go-swagger/go-swagger/cmd/swagger@$(GO_SWAGGER_VERSION)

# local is what we run when testing locally.
# This does breaking change detection against our local git repository.

Expand All @@ -92,6 +99,7 @@ breaking: $(BUF)
.PHONY: build
build: $(BUF)
buf generate
swagger flatten --with-flatten=remove-unused release/openapi/api.swagger.json -o release/openapi/api.swagger.json

# Make sure build is up to date
.PHONY: check
Expand Down
8 changes: 8 additions & 0 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,11 @@ plugins:
opt:
- paths=source_relative
- generate_unbound_methods=true
- name: openapiv2
out: release/openapi
strategy: all
opt:
- generate_unbound_methods=true
- allow_merge
- visibility_restriction_selectors=V2
- merge_file_name=api
9 changes: 7 additions & 2 deletions buf.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ deps:
- remote: buf.build
owner: googleapis
repository: googleapis
commit: 28151c0d0a1641bf938a7672c500e01d
digest: shake256:49215edf8ef57f7863004539deff8834cfb2195113f0b890dd1f67815d9353e28e668019165b9d872395871eeafcbab3ccfdb2b5f11734d3cca95be9e8d139de
commit: f0e53af8f2fc4556b94f482688b57223
digest: shake256:de26a277fc28b8b411ecf58729d78d32fcf15090ffd998a4469225b17889bfb51442eaab04bb7a8d88d203ecdf0a9febd4ffd52c18ed1c2229160c7bd353ca95
- remote: buf.build
owner: grpc-ecosystem
repository: grpc-gateway
commit: f04e50c23f5f40f786d0e8fa3fe3d713
digest: shake256:67b115260e12cb2d6c5d5ce8dbbf3a095c86f0e52b84f9dbd16dec9433b218f8694bc9aadb1d45eb6fd52f5a7029977d460e2d58afb3208ab6c680e7b21c80e4
1 change: 1 addition & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
version: v1
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
build:
lint:
use:
Expand Down
4 changes: 4 additions & 0 deletions post/v1/service.proto
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
syntax = "proto3";

import "google/api/visibility.proto";

package post.v1;

message OperatorStatusRequest {}
Expand All @@ -14,5 +16,7 @@ message OperatorStatusResponse {
}

service OperatorService {
option (google.api.api_visibility).restriction = "V1";

rpc Status(OperatorStatusRequest) returns (OperatorStatusResponse);
}
56 changes: 30 additions & 26 deletions release/go/post/v1/service.pb.go

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

49 changes: 26 additions & 23 deletions release/go/spacemesh/v1/activation.pb.go

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

Loading

0 comments on commit a632ef5

Please sign in to comment.