Skip to content

Commit

Permalink
fix: gen swagger scripts with ns
Browse files Browse the repository at this point in the history
  • Loading branch information
duvbell committed Jan 26, 2024
1 parent 2087445 commit e8040c0
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ proto-format:
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi

update-swagger-docs:
$(BINDIR)/statik -src=client/docs/swagger-ui -dest=client/docs -f -m
$(BINDIR)/statik -src=client/docs/swagger-ui -dest=client/docs -f -m -ns migaloo
@if [ -n "$(git status --porcelain)" ]; then \
echo "\033[91mSwagger docs are out of sync!!!\033[0m";\
exit 1;\
Expand Down
20 changes: 8 additions & 12 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ import (
appparams "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/params"

// unnamed import of statik for swagger UI support
_ "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/client/docs/statik"
"github.com/rakyll/statik/fs"

v3_0_2 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v3_0_2"
v4 "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app/upgrades/v4_1_0"

_ "github.com/White-Whale-Defi-Platform/migaloo-chain/v4/client/docs/statik"
)

const (
Expand Down Expand Up @@ -1108,26 +1109,21 @@ func (app *MigalooApp) AppCodec() codec.Codec {

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

// List the files in the statikFS
fmt.Println("statikFS files: ")
err = fs.Walk(statikFS, "/", func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
fmt.Println("statik path: ", path) // This will log the path of each file in the statikFS
return nil
})
cosmosStaticServer := http.FileServer(cosmosStatikFs)

statikFS, err := fs.NewWithNamespace("migaloo")
if err != nil {
fmt.Println(err)
panic(err)
}

staticServer := http.FileServer(statikFS)

rtr.PathPrefix("/swagger/cosmos-sdk").Handler(http.StripPrefix("/swagger/cosmos-sdk", cosmosStaticServer))
rtr.PathPrefix("/swagger/").Handler(http.StripPrefix("/swagger/", staticServer))
}

Expand Down
5 changes: 3 additions & 2 deletions client/docs/statik/statik.go

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion client/docs/swagger-ui/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
</head>

<body>
<h1>This is a test script</h1>
<div id="swagger-ui"></div>

<script src="swagger-ui-bundle.js"> </script>
Expand Down
1 change: 0 additions & 1 deletion client/docs/swagger-ui/ramdom.html

This file was deleted.

3 changes: 2 additions & 1 deletion cmd/migalood/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"fmt"
"os"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app"
"github.com/White-Whale-Defi-Platform/migaloo-chain/v4/cmd/migalood/cmd"
"github.com/cosmos/cosmos-sdk/server"
svrcmd "github.com/cosmos/cosmos-sdk/server/cmd"

"github.com/White-Whale-Defi-Platform/migaloo-chain/v4/app"
)

func main() {
Expand Down
1 change: 1 addition & 0 deletions scripts/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
./bin/migalood start --home mytestnet

0 comments on commit e8040c0

Please sign in to comment.