node-cnb 1.10.0 → 1.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,10 @@ client.users.pinnedRepos
|
|
|
48
48
|
|
|
49
49
|
## 方法路径
|
|
50
50
|
|
|
51
|
+
方法路径有两种模式
|
|
52
|
+
|
|
53
|
+
### 1.请求路径拼接
|
|
54
|
+
|
|
51
55
|
方法路径为由如下几个元素组成:
|
|
52
56
|
|
|
53
57
|
1. 第一个 `/-/` 前的参数名
|
|
@@ -62,4 +66,24 @@ client.users.pinnedRepos
|
|
|
62
66
|
|
|
63
67
|
对于此规则下方法路径仍然重复的 api,则单独定义在 [pathMethodMap.json](https://cnb.cool/cnb/sdk/node-cnb/-/blob/main/pathMethodMap.json)
|
|
64
68
|
|
|
69
|
+
### 2.Tag+operationId拼接
|
|
70
|
+
|
|
71
|
+
在 swagger json 中可以看到每个方法都有一个 Tag 和 operationId,
|
|
72
|
+
|
|
73
|
+
可以用 `client.<Tag>.<operationId>` 调用:
|
|
74
|
+
|
|
75
|
+
```javascript
|
|
76
|
+
const sdk = require("node-cnb");
|
|
77
|
+
|
|
78
|
+
// 参数分别为 api url 和 访问令牌
|
|
79
|
+
const client = sdk.getClient("https://api.cnb.cool", "xxx");
|
|
80
|
+
|
|
81
|
+
client.Repositories.GetPinnedRepoByID({
|
|
82
|
+
username: "xxx",
|
|
83
|
+
})
|
|
84
|
+
.then((res) => {
|
|
85
|
+
console.log(res);
|
|
86
|
+
});
|
|
87
|
+
```
|
|
88
|
+
|
|
65
89
|
完整api路径请参考 [client.d.ts](https://cnb.cool/cnb/sdk/node-cnb/-/blob/main/src/client.d.ts)
|