Register swagger API (#7246)

* init

* Fix statik gen

* Fix swagger

* Change swagger url

* Fix swagger serve

* remove ibc swagger from legacy docs

* Add old routes config

* Move swagger api to app.go

* add godoc

* Fix inputs

* Fix swagger dir

* Fix statik

* refactor

* fmt

* fix doc

* Fix swagger config check
This commit is contained in:
Anil Kumar Kammari
2020-09-19 00:34:56 +00:00
committed by GitHub
parent d6357e77b4
commit ca7b31dd5d
14 changed files with 29607 additions and 15663 deletions
+1 -15
View File
@@ -11,7 +11,6 @@ import (
"github.com/gorilla/handlers"
"github.com/gorilla/mux"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/rakyll/statik/fs"
"github.com/tendermint/tendermint/libs/log"
tmrpcserver "github.com/tendermint/tendermint/rpc/jsonrpc/server"
@@ -83,10 +82,6 @@ func New(clientCtx client.Context, logger log.Logger) *Server {
// and are delegated to the Tendermint JSON RPC server. The process is
// non-blocking, so an external signal handler must be used.
func (s *Server) Start(cfg config.Config) error {
if cfg.API.Swagger {
s.registerSwaggerUI()
}
if cfg.Telemetry.Enabled {
m, err := telemetry.New(cfg.Telemetry)
if err != nil {
@@ -109,6 +104,7 @@ func (s *Server) Start(cfg config.Config) error {
}
s.registerGRPCRoutes()
s.listener = listener
var h http.Handler = s.Router
@@ -126,16 +122,6 @@ func (s *Server) Close() error {
return s.listener.Close()
}
func (s *Server) registerSwaggerUI() {
statikFS, err := fs.New()
if err != nil {
panic(err)
}
staticServer := http.FileServer(statikFS)
s.Router.PathPrefix("/legacy").Handler(staticServer)
}
func (s *Server) registerGRPCRoutes() {
s.Router.PathPrefix("/").Handler(s.GRPCRouter)
}
+1
View File
@@ -227,6 +227,7 @@ func GetConfig(v *viper.Viper) Config {
},
API: APIConfig{
Enable: v.GetBool("api.enable"),
Swagger: v.GetBool("api.swagger"),
Address: v.GetString("api.address"),
MaxOpenConnections: v.GetUint("api.max-open-connections"),
RPCReadTimeout: v.GetUint("api.rpc-read-timeout"),
+1 -1
View File
@@ -246,7 +246,7 @@ func startInProcess(ctx *Context, clientCtx client.Context, appCreator types.App
WithClient(local.New(tmNode))
apiSrv = api.New(clientCtx, ctx.Logger.With("module", "api-server"))
app.RegisterAPIRoutes(apiSrv)
app.RegisterAPIRoutes(apiSrv, config.API)
errCh := make(chan error)
go func() {
+2 -1
View File
@@ -11,6 +11,7 @@ import (
dbm "github.com/tendermint/tm-db"
"github.com/cosmos/cosmos-sdk/server/api"
"github.com/cosmos/cosmos-sdk/server/config"
)
type (
@@ -31,7 +32,7 @@ type (
Application interface {
abci.Application
RegisterAPIRoutes(*api.Server)
RegisterAPIRoutes(*api.Server, config.APIConfig)
// RegisterGRPCServer registers gRPC services directly with the gRPC
// server.