Skip to content

Commit 08343dc

Browse files
authored
Merge pull request CosmosContracts#537 from CosmosContracts/finish-ignition
Openapi without ignite
2 parents 1401967 + c513b96 commit 08343dc

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

app/app.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"strings"
88

9+
"github.com/CosmosContracts/juno/v12/app/openapiconsole"
910
"github.com/CosmosContracts/juno/v12/docs"
1011
"github.com/cosmos/cosmos-sdk/baseapp"
1112
"github.com/cosmos/cosmos-sdk/client"
@@ -35,7 +36,6 @@ import (
3536
upgradeclient "github.com/cosmos/cosmos-sdk/x/upgrade/client"
3637
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
3738
ibcclientclient "github.com/cosmos/ibc-go/v4/modules/core/02-client/client"
38-
"github.com/ignite-hq/cli/ignite/pkg/openapiconsole"
3939
"github.com/spf13/cast"
4040
abci "github.com/tendermint/tendermint/abci/types"
4141
tmjson "github.com/tendermint/tendermint/libs/json"

app/openapiconsole/console.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package openapiconsole
2+
3+
import (
4+
"embed"
5+
"html/template"
6+
"net/http"
7+
)
8+
9+
//go:embed index.tpl
10+
var index embed.FS
11+
12+
// Handler returns an http handler that servers OpenAPI console for an OpenAPI spec at specURL.
13+
func Handler(title, specURL string) http.HandlerFunc {
14+
t, _ := template.ParseFS(index, "index.tpl")
15+
16+
return func(w http.ResponseWriter, req *http.Request) {
17+
t.Execute(w, struct { //nolint:errcheck
18+
Title string
19+
URL string
20+
}{
21+
title,
22+
specURL,
23+
})
24+
}
25+
}

app/openapiconsole/index.tpl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>{{ .Title }}</title>
6+
<link rel="stylesheet" type="text/css" href="//unpkg.com/[email protected]/swagger-ui.css" />
7+
<link rel="icon" type="image/png" href="//unpkg.com/[email protected]/favicon-16x16.png" />
8+
</head>
9+
<body>
10+
<div id="swagger-ui"></div>
11+
12+
<script src="//unpkg.com/[email protected]/swagger-ui-bundle.js"></script>
13+
<script>
14+
// init Swagger for faucet's openapi.yml.
15+
window.onload = function() {
16+
window.ui = SwaggerUIBundle({
17+
url: {{ .URL }},
18+
dom_id: "#swagger-ui",
19+
deepLinking: true,
20+
layout: "BaseLayout",
21+
});
22+
}
23+
</script>
24+
</body>
25+
</html>

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require (
1313
github.com/golang/protobuf v1.5.2
1414
github.com/gorilla/mux v1.8.0
1515
github.com/grpc-ecosystem/grpc-gateway v1.16.0
16-
github.com/ignite-hq/cli v0.22.1
1716
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230110104305-322e8478dbe8
1817
github.com/prometheus/client_golang v1.14.0
1918
github.com/spf13/cast v1.5.0

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,6 @@ github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj
523523
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
524524
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
525525
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
526-
github.com/ignite-hq/cli v0.22.1 h1:87DQZrbmfM7pNp1HmKRZtxIFydPfYDZJofssRi3yr2E=
527-
github.com/ignite-hq/cli v0.22.1/go.mod h1:E2dM1v4Gy3tZv2X/iUQY/L7HBObBrC5rjajivIPhbWc=
528526
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
529527
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
530528
github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=

0 commit comments

Comments
 (0)