Skip to content

Commit a0d2502

Browse files
authored
docs: update swagger (arkeonetwork#299)
* chore: update buf work * docs: update config and docs * feat: add swagger route to chain * chore: update changelog * chore: update docs * fix: lint go code
1 parent e4d1901 commit a0d2502

13 files changed

+44230
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Contains all the PRs that improved the code without changing the behaviors.
3939
## Fixed
4040
- Fixed code lint
4141
- Fixed ws client issue with event stream
42+
- Fixed swagger issue
4243

4344
# v1.0.2-Prerelease
4445

app/app.go

+5-4
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ package app
66
import (
77
"fmt"
88
"io"
9-
"net/http"
109
"os"
1110

1211
autocliv1 "cosmossdk.io/api/cosmos/autocli/v1"
@@ -64,7 +63,6 @@ import (
6463

6564
"github.com/arkeonetwork/arkeo/app/keepers"
6665
arekoappParams "github.com/arkeonetwork/arkeo/app/params"
67-
"github.com/arkeonetwork/arkeo/docs"
6866

6967
// distrclient "github.com/cosmos/cosmos-sdk/x/distribution/client"
7068
"cosmossdk.io/x/evidence"
@@ -963,8 +961,11 @@ func (app *ArkeoApp) RegisterAPIRoutes(apiSvr *api.Server, apiConfig config.APIC
963961
ModuleBasics.RegisterGRPCGatewayRoutes(clientCtx, apiSvr.GRPCGatewayRouter)
964962

965963
// register app's OpenAPI routes.
966-
apiSvr.Router.Handle("/static/openapi.yml", http.FileServer(http.FS(docs.Docs)))
967-
// apiSvr.Router.HandleFunc("/", openapiconsole.Handler(AppName, "/static/openapi.yml"))
964+
if apiConfig.Swagger {
965+
if err := RegisterSwaggerAPI(apiSvr); err != nil {
966+
panic(err)
967+
}
968+
}
968969
}
969970

970971
// RegisterTxService implements the Application.RegisterTxService method.

app/swagger.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package app
2+
3+
import (
4+
"net/http"
5+
6+
"github.com/cosmos/cosmos-sdk/server/api"
7+
8+
"github.com/arkeonetwork/arkeo/docs"
9+
"github.com/arkeonetwork/arkeo/pkg/openapiconsole"
10+
)
11+
12+
// RegisterSwaggerAPI provides a common function which registers swagger route with API Server
13+
func RegisterSwaggerAPI(apiSvr *api.Server) error {
14+
// register app's OpenAPI routes.
15+
apiSvr.Router.Handle("/static/swagger.min.json", http.FileServer(http.FS(docs.Docs)))
16+
apiSvr.Router.HandleFunc("/swagger", openapiconsole.Handler(AppName+" Swagger UI", "/static/swagger.min.json"))
17+
return nil
18+
}

buf.work.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version: v1
22
directories:
3-
- ./proto
3+
- proto

docs/TESTNET.md

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ curl -s http://seed31.innovationtheory.com:26657/genesis | jq '.result.genesis'
8181
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $HOME/.arkeo/config/app.toml
8282
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"50\"/" $HOME/.arkeo/config/app.toml
8383
sed -i 's|minimum-gas-prices =.*|minimum-gas-prices = "0.001uarkeo"|g' $HOME/.arkeo/config/app.toml
84+
sed -i 's|swagger =.*| swagger = true|g' $HOME/.arkeo/config/app.toml
8485
```
8586
8687
---

docs/proto/config.json

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"swagger": "2.0",
3+
"info": {
4+
"title": "Arkeo - gRPC Gateway docs",
5+
"description": "A REST interface for state queries. \nUsing Cosmos SDK [{sdk-version}](https://github.com/cosmos/cosmos-sdk/releases/tag/{sdk-version})",
6+
"version": "{arkeo-version}"
7+
},
8+
"apis": [
9+
10+
{
11+
"url": "./tmp-swagger-gen/arkeo/arkeo/query.swagger.json",
12+
"tags": {
13+
"add": ["Arkeo"]
14+
},
15+
"operationIds": {
16+
"rename": {
17+
"Params": "ArkeoParams"
18+
}
19+
}
20+
},
21+
{
22+
"url": "./tmp-swagger-gen/arkeo/claim/query.swagger.json",
23+
"tags": {
24+
"add": ["Claim"]
25+
},
26+
"operationIds": {
27+
"rename": {
28+
"Params": "ClaimParams"
29+
}
30+
}
31+
},
32+
{
33+
"url": "https://raw.githubusercontent.com/cosmos/cosmos-sdk/{sdk-version}/client/docs/swagger-ui/swagger.yaml",
34+
"tags": {
35+
"add": ["Cosmos"]
36+
}
37+
}
38+
39+
40+
]
41+
}

docs/static/openapi.yml

-1
This file was deleted.

0 commit comments

Comments
 (0)