Skip to content

Commit

Permalink
fix: generated swagger + openapi
Browse files Browse the repository at this point in the history
  • Loading branch information
freeelancer committed Sep 5, 2024
1 parent e8888ad commit ab8b591
Show file tree
Hide file tree
Showing 8 changed files with 45,212 additions and 58,980 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ release/
.aider*
swagger-proto
tmp-swagger-gen
client/docs/node_modules
26 changes: 23 additions & 3 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ package app

import (
"io"
"net/http"

"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"

_ "cosmossdk.io/api/cosmos/tx/config/v1" // import for side-effects
clienthelpers "cosmossdk.io/client/v2/helpers"
Expand All @@ -19,8 +23,8 @@ import (
_ "cosmossdk.io/x/upgrade" // import for side-effects
upgradekeeper "cosmossdk.io/x/upgrade/keeper"
wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/MANTRA-Chain/mantrachain/docs"
_ "github.com/MANTRA-Chain/mantrachain/x/tokenfactory" // import for side-effects
_ "github.com/MANTRA-Chain/mantrachain/client/docs/statik" // import for side-effects
_ "github.com/MANTRA-Chain/mantrachain/x/tokenfactory" // import for side-effects
tokenfactorykeeper "github.com/MANTRA-Chain/mantrachain/x/tokenfactory/keeper"
abci "github.com/cometbft/cometbft/abci/types"
tmproto "github.com/cometbft/cometbft/proto/tendermint/types"
Expand Down Expand Up @@ -388,14 +392,30 @@ func (app *App) SimulationManager() *module.SimulationManager {
// RegisterAPIRoutes registers all application module routes with the provided
// API server.
func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIConfig) {
clientCtx := apiSvr.ClientCtx

app.App.RegisterAPIRoutes(apiSvr, apiConfig)
// register swagger API in app.go so that other applications can override easily
if err := server.RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil {
panic(err)
}

// register app's OpenAPI routes.
docs.RegisterOpenAPIService(Name, apiSvr.Router)
if apiConfig.Swagger {
RegisterSwaggerAPI(clientCtx, apiSvr.Router)
}
}

// RegisterSwaggerAPI registers swagger route with API Server.
func RegisterSwaggerAPI(ctx client.Context, rtr *mux.Router) {
statikFS, err := fs.New()
if err != nil {
panic(err)
}

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

// GetMaccPerms returns a copy of the module account permissions
Expand Down
938 changes: 603 additions & 335 deletions client/docs/static/openapi/index.html

Large diffs are not rendered by default.

Loading

0 comments on commit ab8b591

Please sign in to comment.