@fxri/swagger2api 1.0.7 → 1.0.9
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/.swaggerrc +1 -1
- package/README.md +2 -1
- package/dist/api/index.d.ts +1129 -18034
- package/dist/api/index.js +291 -10535
- package/dist/index.js +3 -2
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ import axios from "axios";
|
|
|
2
2
|
import { execSync } from "node:child_process";
|
|
3
3
|
import os from "node:os";
|
|
4
4
|
import fs from "node:fs";
|
|
5
|
+
import url from "node:url";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import prompts from "prompts";
|
|
7
8
|
import { getParam, isUrl, saveFile } from "./utils/index.js";
|
|
@@ -32,7 +33,7 @@ let datas = {
|
|
|
32
33
|
/** 用户目录 */
|
|
33
34
|
home: os.homedir(),
|
|
34
35
|
/** 脚本 */
|
|
35
|
-
script: path.resolve(import.meta.
|
|
36
|
+
script: path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "../node_modules/.bin/swagger-typescript-api"),
|
|
36
37
|
/** 参数 */
|
|
37
38
|
param: process.argv.filter((_item, index) => index > 1),
|
|
38
39
|
/** 文件 */
|
|
@@ -65,7 +66,7 @@ function onGenerate(data) {
|
|
|
65
66
|
// 保存文档
|
|
66
67
|
saveFile(datas.file, JSON.stringify(data));
|
|
67
68
|
// 生成接口
|
|
68
|
-
const param = ["generate", "
|
|
69
|
+
const param = ["generate", "-n", `${confs.param.name}.ts`, "-o", path.resolve(confs.param.output), "-p", datas.file, ...datas.param];
|
|
69
70
|
console.log("执行:", execSync(`${datas.script} ${param.join(" ")}`, { cwd: datas.home }).toString());
|
|
70
71
|
// 删除文档
|
|
71
72
|
fs.unlinkSync(datas.file);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fxri/swagger2api",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "基于 swagger-typescript-api,将 Swagger 文档自动转为 TypeScript 格式的 API
|
|
3
|
+
"version": "1.0.9",
|
|
4
|
+
"description": "基于 swagger-typescript-api,将 Swagger 文档自动转为 TypeScript 格式的 API 文件。",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "唐启云",
|