Skip to content

Commit

Permalink
build: fix swagger gen (#1615)
Browse files Browse the repository at this point in the history
Co-authored-by: Ryan Christoffersen <12519942+ryanchristo@users.noreply.github.com>
  • Loading branch information
aleem1314 and ryanchristo authored Nov 22, 2022
1 parent 9fbf67e commit 3d04e45
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 67 deletions.
109 changes: 55 additions & 54 deletions app/client/docs/config.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,59 @@
{
"swagger": "2.0",
"info": {
"title": "Regen Ledger - REST and gRPC Gateway Documentation",
"description": "Documentation describing REST and gRPC endpoints for state queries and broadcasting transactions.",
"version": "v4.0.0"
"swagger": "2.0",
"info": {
"title": "Regen Ledger - REST and gRPC Gateway Documentation",
"description": "Documentation describing REST and gRPC endpoints for state queries and broadcasting transactions.",
"version": "v5.0.0"
},
"apis": [
{
"url": "./app/client/docs/regen/data/v1/query.swagger.json"
},
"apis": [
{
"url": "./app/client/docs/regen/data/v1/query.swagger.json"
},
{
"url": "./app/client/docs/regen/ecocredit/v1/query.swagger.json",
"operationIds": {
"rename": {
"Balance": "Ecocredit/Balance",
"Params": "Ecocredit/Params"
}
}
},
{
"url": "./app/client/docs/regen/ecocredit/basket/v1/query.swagger.json"
},
{
"url": "./app/client/docs/regen/ecocredit/marketplace/v1/query.swagger.json"
},
{
"url": "./app/client/docs/regen/group/v1alpha1/query.swagger.json",
"operationIds": {
"rename": {
"Proposal": "Group/Proposal"
}
}
},
{
"url": "./app/client/docs/swagger-sdk.yaml",
"dereference": {
"circular": "ignore"
},
"tags": {
"rename": {
"Gaia REST": "Tendermint RPC"
}
},
"operationIds": {
"rename": {
"UpgradedConsensusState": "sdk/UpgradedConsensusState"
}
}
},
{
"url": "./app/client/docs/swagger-ibc.yaml",
"dereference": {
"circular": "ignore"
}
{
"url": "./app/client/docs/regen/ecocredit/v1/query.swagger.json",
"operationIds": {
"rename": {
"Balance": "Ecocredit/Balance",
"Params": "Ecocredit/Params",
"AllBalances": "Ecocredit/AllBalances"
}
]
}
},
{
"url": "./app/client/docs/regen/ecocredit/basket/v1/query.swagger.json"
},
{
"url": "./app/client/docs/regen/ecocredit/marketplace/v1/query.swagger.json"
},
{
"url": "./app/client/docs/regen/intertx/v1/query.swagger.json",
"operationIds": {
"rename": {
"InterchainAccount": "Intertx/InterchainAccount"
}
}
},
{
"url": "./app/client/docs/swagger-sdk.yaml",
"dereference": {
"circular": "ignore"
},
"tags": {
"rename": {
"Gaia REST": "Tendermint RPC"
}
},
"operationIds": {
"rename": {
"UpgradedConsensusState": "sdk/UpgradedConsensusState"
}
}
},
{
"url": "./app/client/docs/swagger-ibc.yaml",
"dereference": {
"circular": "ignore"
}
}
]
}
2 changes: 1 addition & 1 deletion app/client/docs/statik/statik.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions proto/buf.gen.swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: v1
plugins:
- name: swagger
out: ../app/client/docs
opt: logtostderr=true,fqn_for_swagger_name=true,simple_operation_ids=true
18 changes: 6 additions & 12 deletions scripts/protoc-swagger-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,16 @@ set -eo pipefail

SWAGGER_DIR=./app/client/docs

cd ./proto

# find all proto directories
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
proto_dirs=$(find ./regen -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)

# loop through proto directories
for dir in $proto_dirs; do

# generate swagger files for query service proto files
query_file=$(find "${dir}" -maxdepth 2 -name 'query.proto')
# generate swagger files (filter query files)
query_file=$(find "${dir}" -maxdepth 1 \( -name 'query.proto' \))
if [[ ! -z "$query_file" ]]; then
buf alpha protoc \
-I "proto" \
-I "third_party/proto" \
"$query_file" \
--swagger_out=${SWAGGER_DIR} \
--swagger_opt=logtostderr=true \
--swagger_opt=fqn_for_swagger_name=true \
--swagger_opt=simple_operation_ids=true
buf generate --template buf.gen.swagger.yaml $query_file
fi
done

0 comments on commit 3d04e45

Please sign in to comment.