Skip to content

Commit

Permalink
feat: add swagger docs (#311)
Browse files Browse the repository at this point in the history
* add swagger docs

* update go.mod

* remove unused file.
  • Loading branch information
puneet2019 authored Mar 27, 2024
1 parent b9dc308 commit 5745ac3
Show file tree
Hide file tree
Showing 21 changed files with 99,346 additions and 4 deletions.
20 changes: 20 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -293,3 +293,23 @@ rm-testcache:
go clean -testcache

.PHONY: test ictest-all ictest-basic ictest-ibchooks ictest-pfm ictest-upgrade ictest-upgrade-local ictest-ibc ictest-pob ictest-lsm ictest-liquidstake


###############################################################################
### Protobuf ###
###############################################################################

protoVer=0.14.0
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
protoImage=$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(protoImageName)

proto-swagger-gen:
@echo "Generating Protobuf Swagger"
#@$(protoImage) sh ./proto/scripts/proto-swagger-gen.sh
./proto/scripts/proto-swagger-gen.sh

proto-clean:
rm -rf tmp-swagger-gen/
rm -rf tmp_deps/

.PHONY: proto-swagger-gen proto-clean
7 changes: 4 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/json"
"fmt"
"io"
"io/fs"
stdlog "log"
"net/http"
"os"
Expand Down Expand Up @@ -49,14 +50,14 @@ import (
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
pobabci "github.com/skip-mev/pob/abci"
"github.com/skip-mev/pob/mempool"
"github.com/spf13/cast"

"github.com/persistenceOne/persistenceCore/v11/app/keepers"
"github.com/persistenceOne/persistenceCore/v11/app/upgrades"
v11_8_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.8.0"
"github.com/persistenceOne/persistenceCore/v11/client/docs"
)

var (
Expand Down Expand Up @@ -488,12 +489,12 @@ func (app *Application) setupPostHandler() {
}

func RegisterSwaggerAPI(rtr *mux.Router) {
statikFS, err := fs.New()
swaggerDir, err := fs.Sub(docs.SwaggerUI, "swagger-ui")
if err != nil {
panic(err)
}

staticServer := http.FileServer(statikFS)
staticServer := http.FileServer(http.FS(swaggerDir))
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer))
}

Expand Down
298 changes: 298 additions & 0 deletions client/docs/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,298 @@
{
"swagger": "2.0",
"info": {
"title": "Persistence - gRPC Gateway docs",
"description": "A REST interface for state queries",
"version": "1.0.0"
},
"apis": [
{
"url": "./tmp-swagger-gen/pstake/liquidstakeibc/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "LiquidstakeIBCParams",
"Deposits": "LiquidstakeIBCDeposits",
"Redelegations": "LiquidstakeIBCRedelegations"
}
}
},
{
"url": "./tmp-swagger-gen/pstake/liquidstake/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "LiquidstakeParams"
}
}
},
{
"url": "./tmp-swagger-gen/pstake/ratesync/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "RateSyncParams",
"HostChain": "RateSyncHostChain"
}
}
},
{
"url": "./tmp-swagger-gen/persistence/epochs/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "EpochsParams",
}
}
},
{
"url": "./tmp-swagger-gen/persistence/halving/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "HalvingParams",
}
}
},
{
"url": "./tmp-swagger-gen/persistence/interchainquery/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "ICQParams",
}
}
},
{
"url": "./tmp-swagger-gen/cosmwasm/wasm/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "WasmdParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/auth/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "AuthParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/bank/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "BankParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/base/tendermint/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "BaseParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/base/node/v1beta1/query.swagger.json"
},
{
"url": "./tmp-swagger-gen/cosmos/distribution/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "DistributionParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/evidence/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "EvidenceParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/gov/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GovParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/gov/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GovV1Params",
"Proposal": "GovV1Proposal",
"Proposals": "GovV1Proposal",
"Vote": "GovV1Vote",
"Votes": "GovV1Votes",
"Deposit": "GovV1Deposit",
"Deposits": "GovV1Deposit",
"TallyResult": "GovV1TallyResult"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/mint/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "MintParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/params/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "Params"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/slashing/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "SlashingParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/staking/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "StakingParams",
"DelegatorValidators": "StakingDelegatorValidators"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/tx/v1beta1/service.swagger.json",
"dereference": {
"circular": "ignore"
}
},
{
"url": "./tmp-swagger-gen/cosmos/upgrade/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "UpgradeParams",
"UpgradedConsensusState": "UpgradeUpgradedConsensusState"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/authz/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "AuthzParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/feegrant/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "FeegrantParams"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/nft/v1beta1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "NftParams",
"Balance": "NftBalance"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/group/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "GroupParams",
"Proposal": "GroupProposal",
"TallyResult": "GroupTallyResult"
}
}
},
{
"url": "./tmp-swagger-gen/cosmos/consensus/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "ConsensusParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/applications/transfer/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "TransferParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/applications/interchain_accounts/controller/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "InterchainAccountsControllerParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/applications/interchain_accounts/host/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "InterchainAccountsHostParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/applications/fee/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "FeeParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/core/client/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "ClientParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/core/connection/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "ConnectionParams"
}
}
},
{
"url": "./tmp-swagger-gen/ibc/core/channel/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "ChannelParams"
}
}
},
{
"url": "./tmp-swagger-gen/packetforward/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "PFMParams"
}
}
},
{
"url": "./tmp-swagger-gen/pob/builder/v1/query.swagger.json",
"operationIds": {
"rename": {
"Params": "POBParams"
}
}
}
]
}
6 changes: 6 additions & 0 deletions client/docs/embed.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package docs

import "embed"

//go:embed swagger-ui
var SwaggerUI embed.FS
Binary file added client/docs/swagger-ui/favicon-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added client/docs/swagger-ui/favicon-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5745ac3

Please sign in to comment.