openapi-ts-request 0.4.3 → 0.4.5
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 +9 -7
- package/dist/bin/cli.js +6 -1
- package/dist/bin/openapi.js +5 -2
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -29,8 +29,8 @@ pnpm i openapi-ts-request -D
|
|
|
29
29
|
|
|
30
30
|
### CosmiConfig
|
|
31
31
|
|
|
32
|
-
在项目根目录新建 ```openapi-ts.config.ts```
|
|
33
|
-
> 配置文件还支持 ***.openapi-ts.ts***, ***openapi-ts.config.cjs*** 等格式,参考 [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#cosmiconfig)
|
|
32
|
+
在项目根目录新建 ```openapi-ts-request.config.ts```
|
|
33
|
+
> 配置文件还支持 ***.openapi-ts-request.ts***, ***openapi-ts-request.config.cjs*** 等格式,参考 [cosmiconfig](https://github.com/cosmiconfig/cosmiconfig?tab=readme-ov-file#cosmiconfig)
|
|
34
34
|
|
|
35
35
|
```ts
|
|
36
36
|
export default {
|
|
@@ -63,7 +63,7 @@ npm run openapi
|
|
|
63
63
|
|
|
64
64
|
### JS
|
|
65
65
|
|
|
66
|
-
任意目录 ```xxx/xxx``` 新建 ```openapi-ts.config.js```
|
|
66
|
+
任意目录 ```xxx/xxx``` 新建 ```openapi-ts-request.config.js```
|
|
67
67
|
|
|
68
68
|
```ts
|
|
69
69
|
const { generateService } = require('openapi-ts-request')
|
|
@@ -74,7 +74,7 @@ generateService({
|
|
|
74
74
|
})
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
在 ```package.json``` 的 ```script``` 中添加命令: ```"openapi": "node xxx/xxx/openapi-ts.config.js"```
|
|
77
|
+
在 ```package.json``` 的 ```script``` 中添加命令: ```"openapi": "node xxx/xxx/openapi-ts-request.config.js"```
|
|
78
78
|
|
|
79
79
|
生成结果:
|
|
80
80
|
|
|
@@ -84,7 +84,7 @@ npm run openapi
|
|
|
84
84
|
|
|
85
85
|
### TS
|
|
86
86
|
|
|
87
|
-
任意目录 ```xxx/xxx``` 新建 ```openapi-ts.config.ts```
|
|
87
|
+
任意目录 ```xxx/xxx``` 新建 ```openapi-ts-request.config.ts```
|
|
88
88
|
|
|
89
89
|
```ts
|
|
90
90
|
const { generateService } = require('openapi-ts-request')
|
|
@@ -95,7 +95,7 @@ generateService({
|
|
|
95
95
|
})
|
|
96
96
|
```
|
|
97
97
|
|
|
98
|
-
在 ```package.json``` 的 ```script``` 中添加命令: ```"openapi": "ts-node xxx/xxx/openapi-ts.config.ts",```
|
|
98
|
+
在 ```package.json``` 的 ```script``` 中添加命令: ```"openapi": "ts-node xxx/xxx/openapi-ts-request.config.ts",```
|
|
99
99
|
|
|
100
100
|
生成结果:
|
|
101
101
|
|
|
@@ -108,9 +108,11 @@ npm run openapi
|
|
|
108
108
|
```bash
|
|
109
109
|
# npm
|
|
110
110
|
npx --package=openapi-ts-request -- openapi -i ./openapi.json -o ./apis
|
|
111
|
+
npx --package=openapi-ts-request -- openapi -i https://petstore3.swagger.io/api/v3/openapi.json -o ./apis
|
|
111
112
|
|
|
112
113
|
# pnpm
|
|
113
|
-
pnpm --package=openapi-ts-request dlx openapi -i ./openapi.json -o ./apis
|
|
114
|
+
pnpm --package=openapi-ts-request@latest dlx openapi -i ./openapi.json -o ./apis
|
|
115
|
+
pnpm --package=openapi-ts-request@latest dlx openapi -i https://petstore3.swagger.io/api/v3/openapi.json -o ./apis
|
|
114
116
|
```
|
|
115
117
|
|
|
116
118
|
### CLI
|
package/dist/bin/cli.js
CHANGED
|
@@ -5,8 +5,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
7
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
8
|
+
const cosmiconfig_typescript_loader_1 = require("cosmiconfig-typescript-loader");
|
|
8
9
|
const index_1 = require("../index");
|
|
9
|
-
const explorerSync = (0, cosmiconfig_1.cosmiconfigSync)('openapi-ts-request'
|
|
10
|
+
const explorerSync = (0, cosmiconfig_1.cosmiconfigSync)('openapi-ts-request', {
|
|
11
|
+
loaders: {
|
|
12
|
+
'.ts': (0, cosmiconfig_typescript_loader_1.TypeScriptLoader)(),
|
|
13
|
+
},
|
|
14
|
+
});
|
|
10
15
|
const config = (_a = explorerSync.search()) === null || _a === void 0 ? void 0 : _a.config;
|
|
11
16
|
function run() {
|
|
12
17
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
package/dist/bin/openapi.js
CHANGED
|
@@ -25,8 +25,11 @@ const params = commander_1.program
|
|
|
25
25
|
.parse(process.argv)
|
|
26
26
|
.opts();
|
|
27
27
|
function getPath(path) {
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const isUrl = path.startsWith('http');
|
|
29
|
+
if (isUrl) {
|
|
30
|
+
return path;
|
|
31
|
+
}
|
|
32
|
+
return (0, path_1.join)(process.cwd(), path);
|
|
30
33
|
}
|
|
31
34
|
function run() {
|
|
32
35
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-request",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.5",
|
|
4
4
|
"description": "Swagger2/OpenAPI3 to TypeScript, request client, request mock service, enum, type field label, JSON Schemas",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"chalk": "^4.1.2",
|
|
27
27
|
"commander": "^12.1.0",
|
|
28
28
|
"cosmiconfig": "^9.0.0",
|
|
29
|
+
"cosmiconfig-typescript-loader": "^5.0.0",
|
|
29
30
|
"glob": "^10.4.2",
|
|
30
31
|
"lodash": "^4.17.21",
|
|
31
32
|
"memoizee": "^0.4.17",
|