Skip to content

Commit

Permalink
chore: add swagger check (#359)
Browse files Browse the repository at this point in the history
* add swagger check

* add protoc-gen-swagger

* fix

* fix version

* fix buf version

* fix swagger
  • Loading branch information
fynnss authored Jul 21, 2023
1 parent 8eb0cff commit c93f6c2
Show file tree
Hide file tree
Showing 4 changed files with 478 additions and 118 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/buf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ jobs:
run: |
export PATH="$PATH:$(go env GOPATH)/bin"
make tools proto-gen-check
- name: Test protobuf swagger changes
run: |
export PATH="$PATH:$(go env GOPATH)/bin"
make tools proto-swagger-check
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ proto-gen:
cd proto && buf generate && cp -r github.com/bnb-chain/greenfield/x/* ../x && cp -r github.com/bnb-chain/greenfield/types/* ../types && rm -rf github.com && go mod tidy

proto-swagger-gen:
sh ./scripts/protoc-swagger-gen.sh
bash ./scripts/protoc-swagger-gen.sh

proto-swagger-check:
bash ./scripts/protoc-swagger-gen.sh
git diff --exit-code

proto-format:
buf format -w
Expand Down
11 changes: 9 additions & 2 deletions scripts/protoc-swagger-gen.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/usr/bin/env bash
#!/bin/bash


which swagger-combine || npm install -g swagger-combine
which protoc-gen-swagger || go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger

swagger-combine -v
buf --version

set -eo pipefail

Expand All @@ -22,4 +29,4 @@ cd ..
swagger-combine ./swagger/config.json -o ./swagger/static/swagger.yaml -f yaml --continueOnConflictingPaths true --includeDefinitions true

# clean swagger files
rm -rf ./tmp-swagger-gen
rm -rf ./tmp-swagger-gen
Loading

0 comments on commit c93f6c2

Please sign in to comment.