Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update swagger generation for 1.19 #2070

Merged
merged 9 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ linters-settings:

- github.com/provenance-io/provenance

- github.com/rakyll/statik/fs

- github.com/spf13/cast
- github.com/spf13/cobra
- github.com/spf13/pflag
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

* nothing

---

## [v1.19.0-rc1](https://github.com/provenance-io/provenance/releases/tag/v1.19.0-rc1) - 2024-06-24

### Features

* Create a script for updating links in the spec docs to proto messages [#2068](https://github.com/provenance-io/provenance/pull/2068).
Expand Down
14 changes: 3 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,9 @@ clean:
rm -rf $(BUILDDIR)/*

format:
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" -not -path "*/statik*" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" -not -path "*/statik*" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" -not -path "*/statik*" | xargs goimports -w -local github.com/provenance-io/provenance
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" | xargs gofmt -w -s
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" | xargs misspell -w
find . -name '*.go' -type f -not -path "./vendor*" -not -path "*.git*" -not -path "*.pb.go" | xargs goimports -w -local github.com/provenance-io/provenance

check-built:
@if [ ! -f "$(BUILDDIR)/provenanced" ]; then \
Expand Down Expand Up @@ -527,14 +527,6 @@ proto-update-deps:
.PHONY: proto-all proto-checks proto-regen proto-gen proto-format proto-lint proto-check-breaking proto-check-breaking-third-party proto-update-deps proto-update-check


##############################
### Docs
##############################
update-swagger-docs: statik proto-swagger-gen
SpicyLemon marked this conversation as resolved.
Show resolved Hide resolved
$(BINDIR)/statik -src=client/docs/swagger-ui -dest=client/docs -f -m

.PHONY: update-swagger-docs

##############################
### Relayer
##############################
Expand Down
205 changes: 205 additions & 0 deletions RELEASE_CHANGELOG.md

Large diffs are not rendered by default.

27 changes: 16 additions & 11 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package app
import (
"encoding/json"
"io"
"io/fs"
"net/http"
"os"
"path/filepath"
Expand All @@ -13,7 +14,6 @@ import (
wasmv2 "github.com/CosmWasm/wasmd/x/wasm/migrations/v2"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
"github.com/spf13/cast"
"github.com/spf13/viper"

Expand Down Expand Up @@ -137,6 +137,7 @@ import (
ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types"

simappparams "github.com/provenance-io/provenance/app/params"
"github.com/provenance-io/provenance/client/docs"
"github.com/provenance-io/provenance/internal/antewrapper"
piohandlers "github.com/provenance-io/provenance/internal/handlers"
"github.com/provenance-io/provenance/internal/pioconfig"
Expand Down Expand Up @@ -185,8 +186,6 @@ import (
triggerkeeper "github.com/provenance-io/provenance/x/trigger/keeper"
triggermodule "github.com/provenance-io/provenance/x/trigger/module"
triggertypes "github.com/provenance-io/provenance/x/trigger/types"

_ "github.com/provenance-io/provenance/client/docs/statik" // registers swagger-ui files with statik
)

var (
Expand Down Expand Up @@ -1277,9 +1276,9 @@ func (app *App) RegisterAPIRoutes(apiSvr *api.Server, apiConfig serverconfig.API
// Register grpc-gateway routes for all modules.
app.BasicModuleManager.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)

// register swagger API from root so that other applications can override easily
if apiConfig.Swagger {
RegisterSwaggerAPI(clientCtx, apiSvr.Router)
// Register swagger API
if err := RegisterSwaggerAPI(apiSvr.ClientCtx, apiSvr.Router, apiConfig.Swagger); err != nil {
panic(err)
}
SpicyLemon marked this conversation as resolved.
Show resolved Hide resolved
}

Expand Down Expand Up @@ -1320,15 +1319,21 @@ func (app *App) AutoCliOpts() autocli.AppOptions {
}
}

// RegisterSwaggerAPI registers swagger route with API Server
func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router) {
statikFS, err := fs.New()
// RegisterSwaggerAPI provides a common function which registers swagger route with API Server
func RegisterSwaggerAPI(_ client.Context, rtr *mux.Router, swaggerEnabled bool) error {
if !swaggerEnabled {
return nil
}

root, err := fs.Sub(docs.SwaggerUI, "swagger-ui")
if err != nil {
panic(err)
return err
}

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

return nil
}

// GetMaccPerms returns a copy of the module account permissions
Expand Down
Loading
Loading