diff --git a/CHANGELOG.md b/CHANGELOG.md index 2bdd9f17..d95ee435 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,7 @@ An '!' indicates a state machine breaking change. - (`x/query`) [#159](https://github.com/KYVENetwork/chain/pull/159) Add pool params back to kyve params query. - (`x/query`) [#160](https://github.com/KYVENetwork/chain/pull/160) Add funders back to pool query. +- [#163](https://github.com/KYVENetwork/chain/pull/163) Add back swagger UI for KYVE and Cosmos REST queries. ## [v1.4.0](https://github.com/KYVENetwork/chain/releases/tag/v1.4.0) - 2023-11-17 diff --git a/app/app.go b/app/app.go index c73a7565..a19460b8 100644 --- a/app/app.go +++ b/app/app.go @@ -4,9 +4,12 @@ import ( "encoding/json" "fmt" "io" + "net/http" "os" "path/filepath" + "github.com/rakyll/statik/fs" + v1p4 "github.com/KYVENetwork/chain/app/upgrades/v1_4" dbm "github.com/cometbft/cometbft-db" abci "github.com/cometbft/cometbft/abci/types" @@ -32,6 +35,8 @@ import ( "github.com/cosmos/cosmos-sdk/version" "github.com/spf13/cast" + kyveDocs "github.com/KYVENetwork/chain/docs" + // Auth "github.com/cosmos/cosmos-sdk/x/auth" "github.com/cosmos/cosmos-sdk/x/auth/ante" @@ -1050,8 +1055,19 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter) // register swagger API from root so that other applications can override easily - if err := server.RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil { - panic(err) + if apiConfig.Swagger { + statikFS, err := fs.New() + if err != nil { + panic(err) + } + + // cosmos swagger ui + staticServer := http.FileServer(statikFS) + apiSvr.Router.PathPrefix("/swagger-cosmos/").Handler(http.StripPrefix("/swagger-cosmos/", staticServer)) + + // kyve swagger ui + apiSvr.Router.Handle("/swagger.yml", http.FileServer(http.FS(kyveDocs.Swagger))) + apiSvr.Router.HandleFunc("/", kyveDocs.Handler(Name, "/swagger.yml")) } } diff --git a/docs/index.tpl b/docs/index.tpl index 8ec84e9e..fdfd895f 100644 --- a/docs/index.tpl +++ b/docs/index.tpl @@ -7,6 +7,12 @@ +
+
+

Cosmos - REST API

+ The native Cosmos queries can be found at: /swagger-cosmos/ +
+