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

Chore/add api namespace head to doc gen / 在生成的 文档中加入 api namespace #6200

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
10 changes: 9 additions & 1 deletion venus-devtool/api-gen/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func init() {
RPCMeta: util.RPCMeta{
Version: 0,
MethodNamespace: "Message",
ApiNamespace: "messager.IMessager",
},
},
util.APIMeta{
Expand All @@ -43,7 +44,8 @@ func init() {
IncludeAll: true,
},
RPCMeta: util.RPCMeta{
Version: 0,
Version: 0,
ApiNamespace: "wallet.IFullAPI",
},
},
util.APIMeta{
Expand All @@ -55,6 +57,7 @@ func init() {
RPCMeta: util.RPCMeta{
Version: 2,
MethodNamespace: "Gateway",
ApiNamespace: "gateway.IGateway",
},
},
util.APIMeta{
Expand All @@ -66,6 +69,7 @@ func init() {
RPCMeta: util.RPCMeta{
Version: 1,
MethodNamespace: "Gateway",
ApiNamespace: "gateway.IGateway",
},
},
util.APIMeta{
Expand All @@ -77,6 +81,7 @@ func init() {
RPCMeta: util.RPCMeta{
Version: 0,
MethodNamespace: "Gateway",
ApiNamespace: "gateway.IGateway",
},
},
util.APIMeta{
Expand All @@ -88,6 +93,7 @@ func init() {
RPCMeta: util.RPCMeta{
Version: 0,
MethodNamespace: "VENUS_MARKET",
ApiNamespace: "v1.IMarket",
},
},
util.APIMeta{
Expand All @@ -99,6 +105,7 @@ func init() {
RPCMeta: util.RPCMeta{
Version: 1,
MethodNamespace: "VENUS_MARKET",
ApiNamespace: "v1.IMarket",
},
},
util.APIMeta{
Expand All @@ -110,6 +117,7 @@ func init() {
RPCMeta: util.RPCMeta{
Version: 0,
MethodNamespace: "VENUS_MARKET_CLIENT",
ApiNamespace: "client.IMarketClient",
},
},
)
Expand Down
14 changes: 9 additions & 5 deletions venus-devtool/api-gen/doc_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,25 @@ func writeAPIInfo(astMeta *util.ASTMeta, rpcMeta util.RPCMeta, groups []MethodGr
if methNs == "" {
methNs = "Filecoin"
}

apiNs := rpcMeta.ApiNamespace

tmpl, err := template.New("curl").Parse(`# Sample code of curl

{{ .StartBash }}
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v{{ .APIVersion }} -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "{{ .Namespace }}.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v{{ .APIVersion }} -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: {{ .APINamespace }}" -H "Authorization: Bearer <token>" -d '{"method": "{{ .Namespace }}.<method>", "params": <Inputs>, "id": 0}'
{{ .EndBash }}
`)
if err != nil {
return fmt.Errorf("parse template: %w", err)
}
err = tmpl.Execute(buf, map[string]interface{}{
"APIVersion": rpcMeta.Version,
"Namespace": methNs,
"StartBash": "```bash",
"EndBash": "```",
"APIVersion": rpcMeta.Version,
"Namespace": methNs,
"APINamespace": apiNs,
"StartBash": "```bash",
"EndBash": "```",
})
if err != nil {
return fmt.Errorf("exec curl template: %w", err)
Expand Down
7 changes: 5 additions & 2 deletions venus-devtool/util/api_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ var ChainAPIPairs = []struct {
IncludeAll: true,
},
RPCMeta: RPCMeta{
Version: 0,
Version: 0,
ApiNamespace: "v1.FullNode",
},
},
},
Expand All @@ -55,7 +56,8 @@ var ChainAPIPairs = []struct {
IncludeAll: true,
},
RPCMeta: RPCMeta{
Version: 1,
Version: 1,
ApiNamespace: "v1.FullNode",
},
},
},
Expand All @@ -67,6 +69,7 @@ type RPCMeta struct {
Version uint32
Namespace string
MethodNamespace string
ApiNamespace string
}

type APIMeta struct {
Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/chain/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "Filecoin.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: v1.FullNode" -H "Authorization: Bearer <token>" -d '{"method": "Filecoin.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/chain/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "Filecoin.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: v1.FullNode" -H "Authorization: Bearer <token>" -d '{"method": "Filecoin.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/gateway/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "Gateway.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: gateway.IGateway" -H "Authorization: Bearer <token>" -d '{"method": "Gateway.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/gateway/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "Gateway.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: gateway.IGateway" -H "Authorization: Bearer <token>" -d '{"method": "Gateway.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/gateway/v2/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v2 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "Gateway.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v2 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: gateway.IGateway" -H "Authorization: Bearer <token>" -d '{"method": "Gateway.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/market/client/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "VENUS_MARKET_CLIENT.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: client.IMarketClient" -H "Authorization: Bearer <token>" -d '{"method": "VENUS_MARKET_CLIENT.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/market/v0/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "VENUS_MARKET.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: v1.IMarket" -H "Authorization: Bearer <token>" -d '{"method": "VENUS_MARKET.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/market/v1/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "VENUS_MARKET.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v1 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: v1.IMarket" -H "Authorization: Bearer <token>" -d '{"method": "VENUS_MARKET.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/messager/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "Message.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: messager.IMessager" -H "Authorization: Bearer <token>" -d '{"method": "Message.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
2 changes: 1 addition & 1 deletion venus-shared/api/wallet/method.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

```bash
# <Inputs> corresponding to the value of Inputs Tag of each API
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <token>" -d '{"method": "Filecoin.<method>", "params": <Inputs>, "id": 0}'
curl http://<ip>:<port>/rpc/v0 -X POST -H "Content-Type: application/json" -H "X-VENUS-API-NAMESPACE: wallet.IFullAPI" -H "Authorization: Bearer <token>" -d '{"method": "Filecoin.<method>", "params": <Inputs>, "id": 0}'
```
# Groups

Expand Down
Loading