forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add swagger for gRPC REST (cosmos#7075)
* swagger gen command added * proto file changed * Add filter for swagger files * Remove loop * Add go-swagger installation * Add swagger mixer command * add swagger options * remove files * Fix swagger-combine * Fix description * remove unnecessary config option * remove go-swagger dependency * refactor * Add proto-gen-swagger installation tool * fix tool * refactor * don't push individual swagger files to repo * refactor * Fix doc * move proto-swagger-gen to a separate target * Fix permissions * Add ibc swagger gen * Update swagger generation doc * cleanup * gofmt * refactor * update Makefile Co-authored-by: anilCSE <[email protected]> Co-authored-by: Federico Kunze <[email protected]>
- Loading branch information
1 parent
4de5e28
commit d02cd16
Showing
10 changed files
with
14,044 additions
and
571 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"title": "Cosmos SDK - GRPC Gateway", | ||
"version": "1.0.0" | ||
}, | ||
"apis": [ | ||
{ | ||
"url": "./cosmos/auth/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "AuthParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/bank/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "BankParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/distribution/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "DistributionParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/evidence/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "EvidenceParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/gov/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "GovParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/mint/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "MintParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/params/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "Params" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/slashing/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "SlashingParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/staking/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "StakingParams", | ||
"DelegatorValidators": "StakingDelegatorValidators" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./cosmos/upgrade/v1beta1/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "UpgradeParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./ibc/channel/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "IBCChannelParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./ibc/client/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "IBCClientParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./ibc/connection/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "IBCConnectionParams" | ||
} | ||
} | ||
}, | ||
{ | ||
"url": "./ibc/transfer/query.swagger.json", | ||
"operationIds": { | ||
"rename": { | ||
"Params": "IBCTransferParams" | ||
} | ||
} | ||
} | ||
] | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eo pipefail | ||
|
||
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) | ||
for dir in $proto_dirs; do | ||
|
||
# generate swagger files (filter query files) | ||
query_file=$(find "${dir}" -maxdepth 1 -name 'query.proto') | ||
if [[ ! -z "$query_file" ]]; then | ||
protoc \ | ||
-I "proto" \ | ||
-I "third_party/proto" \ | ||
"$query_file" \ | ||
--swagger_out=logtostderr=true,stderrthreshold=1000,fqn_for_swagger_name=true,simple_operation_ids=true:. | ||
fi | ||
done | ||
|
||
# combine swagger files | ||
# uses nodejs package `swagger-combine`. | ||
# all the individual swagger files need to be configured in `config.json` for merging | ||
swagger-combine ./client/grpc-gateway/config.json -o ./client/grpc-gateway/swagger.json --continueOnConflictingPaths true --includeDefinitions true | ||
|
||
# clean swagger files | ||
find ./ -name 'query.swagger.json' -exec rm {} \; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.